Skip to content

Commit

Permalink
Apply OpenSAML Test Fix to Remaining Test
Browse files Browse the repository at this point in the history
There was one test that wasn't converted and now it is.

Issue spring-projectsgh-15395
  • Loading branch information
jzheaux committed Aug 30, 2024
1 parent 626610a commit c9d0837
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,12 @@ public void withTrustedMetadataLocationWhenNoCredentialsThenSkipsVerifySignature
TestOpenSamlObjects.signed(descriptor, TestSaml2X509Credentials.assertingPartySigningCredential(),
descriptor.getEntityID());
String serialized = serialize(descriptor);
try (MockWebServer server = new MockWebServer()) {
enqueue(server, serialized, 3);
AssertingPartyMetadataRepository parties = OpenSaml4AssertingPartyMetadataRepository
.withTrustedMetadataLocation(server.url("/").toString())
.build();
assertThat(parties.findByEntityId(registration.getAssertingPartyDetails().getEntityId())).isNotNull();
}
String endpoint = "/" + UUID.randomUUID().toString();
dispatcher.addResponse(endpoint, serialized);
AssertingPartyMetadataRepository parties = OpenSaml4AssertingPartyMetadataRepository
.withTrustedMetadataLocation(web.url(endpoint).toString())
.build();
assertThat(parties.findByEntityId(registration.getAssertingPartyDetails().getEntityId())).isNotNull();
}

@Test
Expand Down Expand Up @@ -362,12 +361,6 @@ private static String serialize(XMLObject object) {
}
}

private static void enqueue(MockWebServer web, String body, int times) {
for (int i = 0; i < times; i++) {
web.enqueue(new MockResponse().setBody(body).setResponseCode(200));
}
}

private static final class MetadataDispatcher extends Dispatcher {

private final MockResponse head = new MockResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,12 @@ public void withTrustedMetadataLocationWhenNoCredentialsThenSkipsVerifySignature
TestOpenSamlObjects.signed(descriptor, TestSaml2X509Credentials.assertingPartySigningCredential(),
descriptor.getEntityID());
String serialized = serialize(descriptor);
try (MockWebServer server = new MockWebServer()) {
enqueue(server, serialized, 3);
AssertingPartyMetadataRepository parties = OpenSaml5AssertingPartyMetadataRepository
.withTrustedMetadataLocation(server.url("/").toString())
.build();
assertThat(parties.findByEntityId(registration.getAssertingPartyDetails().getEntityId())).isNotNull();
}
String endpoint = "/" + UUID.randomUUID().toString();
dispatcher.addResponse(endpoint, serialized);
AssertingPartyMetadataRepository parties = OpenSaml5AssertingPartyMetadataRepository
.withTrustedMetadataLocation(web.url(endpoint).toString())
.build();
assertThat(parties.findByEntityId(registration.getAssertingPartyDetails().getEntityId())).isNotNull();
}

@Test
Expand Down Expand Up @@ -362,12 +361,6 @@ private static String serialize(XMLObject object) {
}
}

private static void enqueue(MockWebServer web, String body, int times) {
for (int i = 0; i < times; i++) {
web.enqueue(new MockResponse().setBody(body).setResponseCode(200));
}
}

private static final class MetadataDispatcher extends Dispatcher {

private final MockResponse head = new MockResponse();
Expand Down

0 comments on commit c9d0837

Please sign in to comment.