|
50 | 50 | import org.apereo.cas.client.validation.AssertionImpl;
|
51 | 51 | import org.instancio.Instancio;
|
52 | 52 | import org.instancio.InstancioApi;
|
| 53 | +import org.instancio.InstancioOfClassApi; |
53 | 54 | import org.instancio.Select;
|
54 | 55 | import org.instancio.generator.Generator;
|
55 | 56 | import org.junit.jupiter.api.Disabled;
|
|
59 | 60 |
|
60 | 61 | import org.springframework.beans.factory.config.BeanDefinition;
|
61 | 62 | import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
| 63 | +import org.springframework.core.ResolvableType; |
62 | 64 | import org.springframework.core.type.filter.AssignableTypeFilter;
|
63 | 65 | import org.springframework.mock.web.MockHttpServletRequest;
|
64 | 66 | import org.springframework.mock.web.MockHttpSession;
|
|
217 | 219 | import org.springframework.security.web.server.firewall.ServerExchangeRejectedException;
|
218 | 220 | import org.springframework.security.web.session.HttpSessionCreatedEvent;
|
219 | 221 | import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs;
|
| 222 | +import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientOutputs; |
| 223 | +import org.springframework.security.web.webauthn.api.AuthenticatorAssertionResponse; |
| 224 | +import org.springframework.security.web.webauthn.api.AuthenticatorAttachment; |
220 | 225 | import org.springframework.security.web.webauthn.api.AuthenticatorTransport;
|
221 | 226 | import org.springframework.security.web.webauthn.api.Bytes;
|
222 | 227 | import org.springframework.security.web.webauthn.api.CredProtectAuthenticationExtensionsClientInput;
|
| 228 | +import org.springframework.security.web.webauthn.api.CredentialPropertiesOutput; |
223 | 229 | import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput;
|
224 | 230 | import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs;
|
| 231 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientOutputs; |
225 | 232 | import org.springframework.security.web.webauthn.api.ImmutablePublicKeyCredentialUserEntity;
|
| 233 | +import org.springframework.security.web.webauthn.api.PublicKeyCredential; |
226 | 234 | import org.springframework.security.web.webauthn.api.PublicKeyCredentialDescriptor;
|
227 | 235 | import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions;
|
228 | 236 | import org.springframework.security.web.webauthn.api.PublicKeyCredentialType;
|
229 | 237 | import org.springframework.security.web.webauthn.api.PublicKeyCredentialUserEntity;
|
| 238 | +import org.springframework.security.web.webauthn.api.TestAuthenticationAssertionResponses; |
230 | 239 | import org.springframework.security.web.webauthn.api.TestBytes;
|
| 240 | +import org.springframework.security.web.webauthn.api.TestPublicKeyCredential; |
231 | 241 | import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialRequestOptions;
|
232 | 242 | import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialUserEntity;
|
233 | 243 | import org.springframework.security.web.webauthn.api.UserVerificationRequirement;
|
234 | 244 | import org.springframework.security.web.webauthn.authentication.WebAuthnAuthentication;
|
| 245 | +import org.springframework.security.web.webauthn.authentication.WebAuthnAuthenticationRequestToken; |
| 246 | +import org.springframework.security.web.webauthn.management.RelyingPartyAuthenticationRequest; |
235 | 247 | import org.springframework.util.ReflectionUtils;
|
236 | 248 |
|
237 | 249 | import static org.assertj.core.api.Assertions.assertThat;
|
@@ -621,6 +633,27 @@ class SpringSecurityCoreVersionSerializableTests {
|
621 | 633 | .allowCredentials(List.of(descriptor))
|
622 | 634 | .build()
|
623 | 635 | );
|
| 636 | + |
| 637 | + CredentialPropertiesOutput credentialOutput = new CredentialPropertiesOutput(false); |
| 638 | + AuthenticationExtensionsClientOutputs outputs = new ImmutableAuthenticationExtensionsClientOutputs(credentialOutput); |
| 639 | + AuthenticatorAssertionResponse response = TestAuthenticationAssertionResponses.createAuthenticatorAssertionResponse() |
| 640 | + .build(); |
| 641 | + PublicKeyCredential<AuthenticatorAssertionResponse> credential = TestPublicKeyCredential.createPublicKeyCredential( |
| 642 | + response, outputs) |
| 643 | + .build(); |
| 644 | + RelyingPartyAuthenticationRequest authRequest = new RelyingPartyAuthenticationRequest( |
| 645 | + TestPublicKeyCredentialRequestOptions.create().build(), |
| 646 | + credential |
| 647 | + ); |
| 648 | + WebAuthnAuthenticationRequestToken requestToken = new WebAuthnAuthenticationRequestToken(authRequest); |
| 649 | + requestToken.setDetails(details); |
| 650 | + generatorByClassName.put(CredentialPropertiesOutput.class, (o) -> credentialOutput); |
| 651 | + generatorByClassName.put(ImmutableAuthenticationExtensionsClientOutputs.class, (o) -> outputs); |
| 652 | + generatorByClassName.put(AuthenticatorAssertionResponse.class, (r) -> response); |
| 653 | + generatorByClassName.put(RelyingPartyAuthenticationRequest.class, (r) -> authRequest); |
| 654 | + generatorByClassName.put(PublicKeyCredential.class, (r) -> credential); |
| 655 | + generatorByClassName.put(WebAuthnAuthenticationRequestToken.class, (r) -> requestToken); |
| 656 | + generatorByClassName.put(AuthenticatorAttachment.class, (r) -> AuthenticatorAttachment.PLATFORM); |
624 | 657 | // @formatter:on
|
625 | 658 | generatorByClassName.put(ImmutablePublicKeyCredentialUserEntity.class,
|
626 | 659 | (r) -> TestPublicKeyCredentialUserEntity.userEntity().id(TestBytes.get()).build());
|
@@ -784,7 +817,11 @@ static Stream<Class<?>> getClassesToSerialize() throws Exception {
|
784 | 817 | }
|
785 | 818 |
|
786 | 819 | private static InstancioApi<?> instancioWithDefaults(Class<?> clazz) {
|
787 |
| - InstancioApi<?> instancio = Instancio.of(clazz); |
| 820 | + InstancioOfClassApi<?> instancio = Instancio.of(clazz); |
| 821 | + ResolvableType[] generics = ResolvableType.forClass(clazz).getGenerics(); |
| 822 | + for (ResolvableType type : generics) { |
| 823 | + instancio.withTypeParameters(type.resolve()); |
| 824 | + } |
788 | 825 | if (generatorByClassName.containsKey(clazz)) {
|
789 | 826 | instancio.supply(Select.all(clazz), generatorByClassName.get(clazz));
|
790 | 827 | }
|
|
0 commit comments