Apply OpenSAML Test Fix to Remaining Test

There was one test that wasn't converted and now it is.

Issue gh-15395
This commit is contained in:
Josh Cummings 2024-08-30 10:21:19 -06:00
parent 626610a975
commit c9d083717f
No known key found for this signature in database
GPG Key ID: A306A51F43B8E5A5
2 changed files with 12 additions and 26 deletions

View File

@ -261,13 +261,12 @@ public class OpenSaml4AssertingPartyMetadataRepositoryTests {
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
@ -362,12 +361,6 @@ public class OpenSaml4AssertingPartyMetadataRepositoryTests {
}
}
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();

View File

@ -261,13 +261,12 @@ public class OpenSaml5AssertingPartyMetadataRepositoryTests {
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
@ -362,12 +361,6 @@ public class OpenSaml5AssertingPartyMetadataRepositoryTests {
}
}
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();