Updated TESTMITREidDataService to reflect changes to MITREidDataService
parent
9d2ec0b845
commit
aadc011104
|
@ -39,7 +39,6 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.logging.Level;
|
|
||||||
import org.mitre.jose.JWEAlgorithmEmbed;
|
import org.mitre.jose.JWEAlgorithmEmbed;
|
||||||
import org.mitre.jose.JWEEncryptionMethodEmbed;
|
import org.mitre.jose.JWEEncryptionMethodEmbed;
|
||||||
import org.mitre.jose.JWSAlgorithmEmbed;
|
import org.mitre.jose.JWSAlgorithmEmbed;
|
||||||
|
@ -740,6 +739,7 @@ public class MITREidDataService_1_0 implements MITREidDataService {
|
||||||
Collection<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
|
Collection<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
|
||||||
Map<String, String> authorizationParameters = new HashMap<String, String>();
|
Map<String, String> authorizationParameters = new HashMap<String, String>();
|
||||||
Map<String, String> approvalParameters = new HashMap<String, String>();
|
Map<String, String> approvalParameters = new HashMap<String, String>();
|
||||||
|
//Set<String> responseTypes = new HashSet<String>();
|
||||||
String redirectUri = null;
|
String redirectUri = null;
|
||||||
String clientId = null;
|
String clientId = null;
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
|
@ -776,6 +776,10 @@ public class MITREidDataService_1_0 implements MITREidDataService {
|
||||||
}
|
}
|
||||||
} else if (name.equals("redirectUri")) {
|
} else if (name.equals("redirectUri")) {
|
||||||
redirectUri = reader.nextString();
|
redirectUri = reader.nextString();
|
||||||
|
} else if (name.equals("responseTypes")) {
|
||||||
|
//already contained in authorizationParameters
|
||||||
|
//responseTypes = readSet(reader);
|
||||||
|
reader.skipValue();
|
||||||
} else {
|
} else {
|
||||||
reader.skipValue();
|
reader.skipValue();
|
||||||
}
|
}
|
||||||
|
@ -862,6 +866,10 @@ public class MITREidDataService_1_0 implements MITREidDataService {
|
||||||
|
|
||||||
Map<Long, Long> whitelistedSiteOldToNewIdMap = new HashMap<Long, Long>();
|
Map<Long, Long> whitelistedSiteOldToNewIdMap = new HashMap<Long, Long>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param reader
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
private void readWhitelistedSites(JsonReader reader) throws IOException {
|
private void readWhitelistedSites(JsonReader reader) throws IOException {
|
||||||
reader.beginArray();
|
reader.beginArray();
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
|
@ -902,6 +910,10 @@ public class MITREidDataService_1_0 implements MITREidDataService {
|
||||||
logger.info("Done reading whitelisted sites");
|
logger.info("Done reading whitelisted sites");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param reader
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
private void readBlacklistedSites(JsonReader reader) throws IOException {
|
private void readBlacklistedSites(JsonReader reader) throws IOException {
|
||||||
reader.beginArray();
|
reader.beginArray();
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
|
|
|
@ -35,13 +35,16 @@ import org.mockito.Mockito;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import org.mitre.openid.connect.model.BlacklistedSite;
|
||||||
|
import org.mitre.openid.connect.model.WhitelistedSite;
|
||||||
|
import org.mitre.openid.connect.repository.BlacklistedSiteRepository;
|
||||||
|
import org.mitre.openid.connect.repository.WhitelistedSiteRepository;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestMITREidDataService_1_0 {
|
public class TestMITREidDataService_1_0 {
|
||||||
|
@ -50,6 +53,10 @@ public class TestMITREidDataService_1_0 {
|
||||||
private OAuth2ClientRepository clientRepository;
|
private OAuth2ClientRepository clientRepository;
|
||||||
@Mock
|
@Mock
|
||||||
private ApprovedSiteRepository approvedSiteRepository;
|
private ApprovedSiteRepository approvedSiteRepository;
|
||||||
|
@Mock
|
||||||
|
private WhitelistedSiteRepository wlSiteRepository;
|
||||||
|
@Mock
|
||||||
|
private BlacklistedSiteRepository blSiteRepository;
|
||||||
@Mock
|
@Mock
|
||||||
private AuthenticationHolderRepository authHolderRepository;
|
private AuthenticationHolderRepository authHolderRepository;
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -94,6 +101,8 @@ public class TestMITREidDataService_1_0 {
|
||||||
|
|
||||||
Mockito.when(clientRepository.getAllClients()).thenReturn(allClients);
|
Mockito.when(clientRepository.getAllClients()).thenReturn(allClients);
|
||||||
Mockito.when(approvedSiteRepository.getAll()).thenReturn(new HashSet<ApprovedSite>());
|
Mockito.when(approvedSiteRepository.getAll()).thenReturn(new HashSet<ApprovedSite>());
|
||||||
|
Mockito.when(wlSiteRepository.getAll()).thenReturn(new HashSet<WhitelistedSite>());
|
||||||
|
Mockito.when(blSiteRepository.getAll()).thenReturn(new HashSet<BlacklistedSite>());
|
||||||
Mockito.when(authHolderRepository.getAll()).thenReturn(new HashSet<AuthenticationHolderEntity>());
|
Mockito.when(authHolderRepository.getAll()).thenReturn(new HashSet<AuthenticationHolderEntity>());
|
||||||
Mockito.when(tokenRepository.getAllAccessTokens()).thenReturn(new HashSet<OAuth2AccessTokenEntity>());
|
Mockito.when(tokenRepository.getAllAccessTokens()).thenReturn(new HashSet<OAuth2AccessTokenEntity>());
|
||||||
Mockito.when(tokenRepository.getAllRefreshTokens()).thenReturn(new HashSet<OAuth2RefreshTokenEntity>());
|
Mockito.when(tokenRepository.getAllRefreshTokens()).thenReturn(new HashSet<OAuth2RefreshTokenEntity>());
|
||||||
|
@ -119,6 +128,8 @@ public class TestMITREidDataService_1_0 {
|
||||||
// make sure all the root elements are there
|
// make sure all the root elements are there
|
||||||
assertThat(config.has(MITREidDataService.CLIENTS), is(true));
|
assertThat(config.has(MITREidDataService.CLIENTS), is(true));
|
||||||
assertThat(config.has(MITREidDataService.GRANTS), is(true));
|
assertThat(config.has(MITREidDataService.GRANTS), is(true));
|
||||||
|
assertThat(config.has(MITREidDataService.WHITELISTEDSITES), is(true));
|
||||||
|
assertThat(config.has(MITREidDataService.BLACKLISTEDSITES), is(true));
|
||||||
assertThat(config.has(MITREidDataService.REFRESHTOKENS), is(true));
|
assertThat(config.has(MITREidDataService.REFRESHTOKENS), is(true));
|
||||||
assertThat(config.has(MITREidDataService.ACCESSTOKENS), is(true));
|
assertThat(config.has(MITREidDataService.ACCESSTOKENS), is(true));
|
||||||
assertThat(config.has(MITREidDataService.SYSTEMSCOPES), is(true));
|
assertThat(config.has(MITREidDataService.SYSTEMSCOPES), is(true));
|
||||||
|
@ -127,6 +138,8 @@ public class TestMITREidDataService_1_0 {
|
||||||
// make sure the root elements are all arrays
|
// make sure the root elements are all arrays
|
||||||
assertThat(config.get(MITREidDataService.CLIENTS).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.CLIENTS).isJsonArray(), is(true));
|
||||||
assertThat(config.get(MITREidDataService.GRANTS).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.GRANTS).isJsonArray(), is(true));
|
||||||
|
assertThat(config.get(MITREidDataService.WHITELISTEDSITES).isJsonArray(), is(true));
|
||||||
|
assertThat(config.get(MITREidDataService.BLACKLISTEDSITES).isJsonArray(), is(true));
|
||||||
assertThat(config.get(MITREidDataService.REFRESHTOKENS).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.REFRESHTOKENS).isJsonArray(), is(true));
|
||||||
assertThat(config.get(MITREidDataService.ACCESSTOKENS).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.ACCESSTOKENS).isJsonArray(), is(true));
|
||||||
assertThat(config.get(MITREidDataService.SYSTEMSCOPES).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.SYSTEMSCOPES).isJsonArray(), is(true));
|
||||||
|
@ -199,6 +212,8 @@ public class TestMITREidDataService_1_0 {
|
||||||
|
|
||||||
Mockito.when(clientRepository.getAllClients()).thenReturn(new HashSet<ClientDetailsEntity>());
|
Mockito.when(clientRepository.getAllClients()).thenReturn(new HashSet<ClientDetailsEntity>());
|
||||||
Mockito.when(approvedSiteRepository.getAll()).thenReturn(new HashSet<ApprovedSite>());
|
Mockito.when(approvedSiteRepository.getAll()).thenReturn(new HashSet<ApprovedSite>());
|
||||||
|
Mockito.when(wlSiteRepository.getAll()).thenReturn(new HashSet<WhitelistedSite>());
|
||||||
|
Mockito.when(blSiteRepository.getAll()).thenReturn(new HashSet<BlacklistedSite>());
|
||||||
Mockito.when(authHolderRepository.getAll()).thenReturn(new HashSet<AuthenticationHolderEntity>());
|
Mockito.when(authHolderRepository.getAll()).thenReturn(new HashSet<AuthenticationHolderEntity>());
|
||||||
Mockito.when(tokenRepository.getAllAccessTokens()).thenReturn(new HashSet<OAuth2AccessTokenEntity>());
|
Mockito.when(tokenRepository.getAllAccessTokens()).thenReturn(new HashSet<OAuth2AccessTokenEntity>());
|
||||||
Mockito.when(tokenRepository.getAllRefreshTokens()).thenReturn(new HashSet<OAuth2RefreshTokenEntity>());
|
Mockito.when(tokenRepository.getAllRefreshTokens()).thenReturn(new HashSet<OAuth2RefreshTokenEntity>());
|
||||||
|
@ -224,6 +239,8 @@ public class TestMITREidDataService_1_0 {
|
||||||
// make sure all the root elements are there
|
// make sure all the root elements are there
|
||||||
assertThat(config.has(MITREidDataService.CLIENTS), is(true));
|
assertThat(config.has(MITREidDataService.CLIENTS), is(true));
|
||||||
assertThat(config.has(MITREidDataService.GRANTS), is(true));
|
assertThat(config.has(MITREidDataService.GRANTS), is(true));
|
||||||
|
assertThat(config.has(MITREidDataService.WHITELISTEDSITES), is(true));
|
||||||
|
assertThat(config.has(MITREidDataService.BLACKLISTEDSITES), is(true));
|
||||||
assertThat(config.has(MITREidDataService.REFRESHTOKENS), is(true));
|
assertThat(config.has(MITREidDataService.REFRESHTOKENS), is(true));
|
||||||
assertThat(config.has(MITREidDataService.ACCESSTOKENS), is(true));
|
assertThat(config.has(MITREidDataService.ACCESSTOKENS), is(true));
|
||||||
assertThat(config.has(MITREidDataService.SYSTEMSCOPES), is(true));
|
assertThat(config.has(MITREidDataService.SYSTEMSCOPES), is(true));
|
||||||
|
@ -232,6 +249,8 @@ public class TestMITREidDataService_1_0 {
|
||||||
// make sure the root elements are all arrays
|
// make sure the root elements are all arrays
|
||||||
assertThat(config.get(MITREidDataService.CLIENTS).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.CLIENTS).isJsonArray(), is(true));
|
||||||
assertThat(config.get(MITREidDataService.GRANTS).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.GRANTS).isJsonArray(), is(true));
|
||||||
|
assertThat(config.get(MITREidDataService.WHITELISTEDSITES).isJsonArray(), is(true));
|
||||||
|
assertThat(config.get(MITREidDataService.BLACKLISTEDSITES).isJsonArray(), is(true));
|
||||||
assertThat(config.get(MITREidDataService.REFRESHTOKENS).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.REFRESHTOKENS).isJsonArray(), is(true));
|
||||||
assertThat(config.get(MITREidDataService.ACCESSTOKENS).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.ACCESSTOKENS).isJsonArray(), is(true));
|
||||||
assertThat(config.get(MITREidDataService.SYSTEMSCOPES).isJsonArray(), is(true));
|
assertThat(config.get(MITREidDataService.SYSTEMSCOPES).isJsonArray(), is(true));
|
||||||
|
@ -304,6 +323,8 @@ public class TestMITREidDataService_1_0 {
|
||||||
"\"" + MITREidDataService.ACCESSTOKENS + "\": [], " +
|
"\"" + MITREidDataService.ACCESSTOKENS + "\": [], " +
|
||||||
"\"" + MITREidDataService.REFRESHTOKENS + "\": [], " +
|
"\"" + MITREidDataService.REFRESHTOKENS + "\": [], " +
|
||||||
"\"" + MITREidDataService.GRANTS + "\": [], " +
|
"\"" + MITREidDataService.GRANTS + "\": [], " +
|
||||||
|
"\"" + MITREidDataService.WHITELISTEDSITES + "\": [], " +
|
||||||
|
"\"" + MITREidDataService.BLACKLISTEDSITES + "\": [], " +
|
||||||
"\"" + MITREidDataService.AUTHENTICATIONHOLDERS + "\": [], " +
|
"\"" + MITREidDataService.AUTHENTICATIONHOLDERS + "\": [], " +
|
||||||
"\"" + MITREidDataService.SYSTEMSCOPES + "\": [" +
|
"\"" + MITREidDataService.SYSTEMSCOPES + "\": [" +
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue