Skip to content

Commit 4a382f2

Browse files
committed
updated unit tests to new structure
1 parent 8c822c0 commit 4a382f2

File tree

3 files changed

+6
-33
lines changed

3 files changed

+6
-33
lines changed

openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_0.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,6 @@ public void testImportGrants() throws IOException, ParseException {
578578
Date creationDate1 = formatter.parse("2014-09-10T22:49:44.090+0000", Locale.ENGLISH);
579579
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
580580

581-
WhitelistedSite mockWlSite1 = mock(WhitelistedSite.class);
582-
when(mockWlSite1.getId()).thenReturn(1L);
583-
584581
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
585582
when(mockToken1.getId()).thenReturn(1L);
586583

@@ -590,7 +587,6 @@ public void testImportGrants() throws IOException, ParseException {
590587
site1.setCreationDate(creationDate1);
591588
site1.setAccessDate(accessDate1);
592589
site1.setUserId("user1");
593-
site1.setWhitelistedSite(mockWlSite1);
594590
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
595591
site1.setApprovedAccessTokens(ImmutableSet.of(mockToken1));
596592

@@ -671,8 +667,8 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
671667
});
672668

673669
dataService.importData(reader);
674-
//2 for sites, 1 for updating access token ref on #1, 1 more for updating whitelistedSite ref on #2
675-
verify(approvedSiteRepository, times(4)).save(capturedApprovedSites.capture());
670+
//2 for sites, 1 for updating access token ref on #1
671+
verify(approvedSiteRepository, times(3)).save(capturedApprovedSites.capture());
676672

677673
List<ApprovedSite> savedSites = new ArrayList(fakeDb.values());
678674

@@ -682,7 +678,6 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
682678
assertThat(savedSites.get(0).getAccessDate(), equalTo(site1.getAccessDate()));
683679
assertThat(savedSites.get(0).getCreationDate(), equalTo(site1.getCreationDate()));
684680
assertThat(savedSites.get(0).getAllowedScopes(), equalTo(site1.getAllowedScopes()));
685-
assertThat(savedSites.get(0).getIsWhitelisted(), equalTo(site1.getIsWhitelisted()));
686681
assertThat(savedSites.get(0).getTimeoutDate(), equalTo(site1.getTimeoutDate()));
687682
assertThat(savedSites.get(0).getApprovedAccessTokens().size(), equalTo(site1.getApprovedAccessTokens().size()));
688683

@@ -691,7 +686,6 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
691686
assertThat(savedSites.get(1).getCreationDate(), equalTo(site2.getCreationDate()));
692687
assertThat(savedSites.get(1).getAllowedScopes(), equalTo(site2.getAllowedScopes()));
693688
assertThat(savedSites.get(1).getTimeoutDate(), equalTo(site2.getTimeoutDate()));
694-
assertThat(savedSites.get(1).getIsWhitelisted(), equalTo(site2.getIsWhitelisted()));
695689
assertThat(savedSites.get(1).getApprovedAccessTokens().size(), equalTo(site2.getApprovedAccessTokens().size()));
696690
}
697691

openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_1.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,6 @@ public void testImportGrants() throws IOException, ParseException {
582582
Date creationDate1 = formatter.parse("2014-09-10T22:49:44.090+0000", Locale.ENGLISH);
583583
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
584584

585-
WhitelistedSite mockWlSite1 = mock(WhitelistedSite.class);
586-
when(mockWlSite1.getId()).thenReturn(1L);
587-
588585
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
589586
when(mockToken1.getId()).thenReturn(1L);
590587

@@ -594,7 +591,6 @@ public void testImportGrants() throws IOException, ParseException {
594591
site1.setCreationDate(creationDate1);
595592
site1.setAccessDate(accessDate1);
596593
site1.setUserId("user1");
597-
site1.setWhitelistedSite(mockWlSite1);
598594
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
599595
site1.setApprovedAccessTokens(ImmutableSet.of(mockToken1));
600596

@@ -675,8 +671,8 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
675671
});
676672

677673
dataService.importData(reader);
678-
//2 for sites, 1 for updating access token ref on #1, 1 more for updating whitelistedSite ref on #2
679-
verify(approvedSiteRepository, times(4)).save(capturedApprovedSites.capture());
674+
//2 for sites, 1 for updating access token ref on #1
675+
verify(approvedSiteRepository, times(3)).save(capturedApprovedSites.capture());
680676

681677
List<ApprovedSite> savedSites = new ArrayList(fakeDb.values());
682678

@@ -686,7 +682,6 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
686682
assertThat(savedSites.get(0).getAccessDate(), equalTo(site1.getAccessDate()));
687683
assertThat(savedSites.get(0).getCreationDate(), equalTo(site1.getCreationDate()));
688684
assertThat(savedSites.get(0).getAllowedScopes(), equalTo(site1.getAllowedScopes()));
689-
assertThat(savedSites.get(0).getIsWhitelisted(), equalTo(site1.getIsWhitelisted()));
690685
assertThat(savedSites.get(0).getTimeoutDate(), equalTo(site1.getTimeoutDate()));
691686
assertThat(savedSites.get(0).getApprovedAccessTokens().size(), equalTo(site1.getApprovedAccessTokens().size()));
692687

@@ -695,7 +690,6 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
695690
assertThat(savedSites.get(1).getCreationDate(), equalTo(site2.getCreationDate()));
696691
assertThat(savedSites.get(1).getAllowedScopes(), equalTo(site2.getAllowedScopes()));
697692
assertThat(savedSites.get(1).getTimeoutDate(), equalTo(site2.getTimeoutDate()));
698-
assertThat(savedSites.get(1).getIsWhitelisted(), equalTo(site2.getIsWhitelisted()));
699693
assertThat(savedSites.get(1).getApprovedAccessTokens().size(), equalTo(site2.getApprovedAccessTokens().size()));
700694
}
701695

openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_2.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,9 +1140,6 @@ public void testExportGrants() throws IOException, ParseException {
11401140
Date creationDate1 = formatter.parse("2014-09-10T22:49:44.090+0000", Locale.ENGLISH);
11411141
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
11421142

1143-
WhitelistedSite mockWlSite1 = mock(WhitelistedSite.class);
1144-
when(mockWlSite1.getId()).thenReturn(1L);
1145-
11461143
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
11471144
when(mockToken1.getId()).thenReturn(1L);
11481145

@@ -1152,7 +1149,6 @@ public void testExportGrants() throws IOException, ParseException {
11521149
site1.setCreationDate(creationDate1);
11531150
site1.setAccessDate(accessDate1);
11541151
site1.setUserId("user1");
1155-
site1.setWhitelistedSite(mockWlSite1);
11561152
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
11571153
site1.setApprovedAccessTokens(ImmutableSet.of(mockToken1));
11581154

@@ -1247,11 +1243,6 @@ public void testExportGrants() throws IOException, ParseException {
12471243
}
12481244
assertThat(site.get("userId").getAsString(), equalTo(compare.getUserId()));
12491245
assertThat(jsonArrayToStringSet(site.getAsJsonArray("allowedScopes")), equalTo(compare.getAllowedScopes()));
1250-
if (site.get("whitelistedSiteId").isJsonNull()) {
1251-
assertNull(compare.getWhitelistedSite());
1252-
} else {
1253-
assertThat(site.get("whitelistedSiteId").getAsLong(), equalTo(compare.getWhitelistedSite().getId()));
1254-
}
12551246
if (site.get("approvedAccessTokens").isJsonNull() || site.getAsJsonArray("approvedAccessTokens") == null) {
12561247
assertTrue(compare.getApprovedAccessTokens() == null || compare.getApprovedAccessTokens().isEmpty());
12571248
} else {
@@ -1274,9 +1265,6 @@ public void testImportGrants() throws IOException, ParseException {
12741265
Date creationDate1 = formatter.parse("2014-09-10T22:49:44.090+0000", Locale.ENGLISH);
12751266
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
12761267

1277-
WhitelistedSite mockWlSite1 = mock(WhitelistedSite.class);
1278-
when(mockWlSite1.getId()).thenReturn(1L);
1279-
12801268
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
12811269
when(mockToken1.getId()).thenReturn(1L);
12821270

@@ -1286,7 +1274,6 @@ public void testImportGrants() throws IOException, ParseException {
12861274
site1.setCreationDate(creationDate1);
12871275
site1.setAccessDate(accessDate1);
12881276
site1.setUserId("user1");
1289-
site1.setWhitelistedSite(mockWlSite1);
12901277
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
12911278
site1.setApprovedAccessTokens(ImmutableSet.of(mockToken1));
12921279

@@ -1367,8 +1354,8 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
13671354
});
13681355

13691356
dataService.importData(reader);
1370-
//2 for sites, 1 for updating access token ref on #1, 1 more for updating whitelistedSite ref on #2
1371-
verify(approvedSiteRepository, times(4)).save(capturedApprovedSites.capture());
1357+
//2 for sites, 1 for updating access token ref on #1
1358+
verify(approvedSiteRepository, times(3)).save(capturedApprovedSites.capture());
13721359

13731360
List<ApprovedSite> savedSites = new ArrayList(fakeDb.values());
13741361

@@ -1378,7 +1365,6 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
13781365
assertThat(savedSites.get(0).getAccessDate(), equalTo(site1.getAccessDate()));
13791366
assertThat(savedSites.get(0).getCreationDate(), equalTo(site1.getCreationDate()));
13801367
assertThat(savedSites.get(0).getAllowedScopes(), equalTo(site1.getAllowedScopes()));
1381-
assertThat(savedSites.get(0).getIsWhitelisted(), equalTo(site1.getIsWhitelisted()));
13821368
assertThat(savedSites.get(0).getTimeoutDate(), equalTo(site1.getTimeoutDate()));
13831369
assertThat(savedSites.get(0).getApprovedAccessTokens().size(), equalTo(site1.getApprovedAccessTokens().size()));
13841370

@@ -1387,7 +1373,6 @@ public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwa
13871373
assertThat(savedSites.get(1).getCreationDate(), equalTo(site2.getCreationDate()));
13881374
assertThat(savedSites.get(1).getAllowedScopes(), equalTo(site2.getAllowedScopes()));
13891375
assertThat(savedSites.get(1).getTimeoutDate(), equalTo(site2.getTimeoutDate()));
1390-
assertThat(savedSites.get(1).getIsWhitelisted(), equalTo(site2.getIsWhitelisted()));
13911376
assertThat(savedSites.get(1).getApprovedAccessTokens().size(), equalTo(site2.getApprovedAccessTokens().size()));
13921377
}
13931378

0 commit comments

Comments
 (0)