|
50 | 50 | import org.instancio.InstancioApi; |
51 | 51 | import org.instancio.Select; |
52 | 52 | import org.instancio.generator.Generator; |
53 | | -import org.junit.jupiter.api.Disabled; |
54 | 53 | import org.junit.jupiter.api.Test; |
55 | 54 | import org.junit.jupiter.params.ParameterizedTest; |
56 | 55 | import org.junit.jupiter.params.provider.MethodSource; |
|
196 | 195 | import org.springframework.security.web.firewall.RequestRejectedException; |
197 | 196 | import org.springframework.security.web.server.firewall.ServerExchangeRejectedException; |
198 | 197 | import org.springframework.security.web.session.HttpSessionCreatedEvent; |
| 198 | +import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs; |
| 199 | +import org.springframework.security.web.webauthn.api.AuthenticatorTransport; |
| 200 | +import org.springframework.security.web.webauthn.api.Bytes; |
| 201 | +import org.springframework.security.web.webauthn.api.CredProtectAuthenticationExtensionsClientInput; |
| 202 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput; |
| 203 | +import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs; |
| 204 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialDescriptor; |
| 205 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialRequestOptions; |
| 206 | +import org.springframework.security.web.webauthn.api.PublicKeyCredentialType; |
| 207 | +import org.springframework.security.web.webauthn.api.TestBytes; |
| 208 | +import org.springframework.security.web.webauthn.api.TestPublicKeyCredentialRequestOptions; |
| 209 | +import org.springframework.security.web.webauthn.api.UserVerificationRequirement; |
199 | 210 | import org.springframework.util.ReflectionUtils; |
200 | 211 |
|
201 | 212 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -515,6 +526,39 @@ class SpringSecurityCoreVersionSerializableTests { |
515 | 526 | (r) -> new AuthenticationSwitchUserEvent(authentication, user)); |
516 | 527 | generatorByClassName.put(HttpSessionCreatedEvent.class, |
517 | 528 | (r) -> new HttpSessionCreatedEvent(new MockHttpSession())); |
| 529 | + |
| 530 | + // webauthn |
| 531 | + CredProtectAuthenticationExtensionsClientInput.CredProtect credProtect = new CredProtectAuthenticationExtensionsClientInput.CredProtect( |
| 532 | + CredProtectAuthenticationExtensionsClientInput.CredProtect.ProtectionPolicy.USER_VERIFICATION_OPTIONAL, |
| 533 | + true); |
| 534 | + Bytes id = TestBytes.get(); |
| 535 | + AuthenticationExtensionsClientInputs inputs = new ImmutableAuthenticationExtensionsClientInputs( |
| 536 | + ImmutableAuthenticationExtensionsClientInput.credProps); |
| 537 | + // @formatter:off |
| 538 | + PublicKeyCredentialDescriptor descriptor = PublicKeyCredentialDescriptor.builder() |
| 539 | + .id(id) |
| 540 | + .type(PublicKeyCredentialType.PUBLIC_KEY) |
| 541 | + .transports(Set.of(AuthenticatorTransport.USB)) |
| 542 | + .build(); |
| 543 | + // @formatter:on |
| 544 | + generatorByClassName.put(AuthenticatorTransport.class, (a) -> AuthenticatorTransport.USB); |
| 545 | + generatorByClassName.put(PublicKeyCredentialType.class, (k) -> PublicKeyCredentialType.PUBLIC_KEY); |
| 546 | + generatorByClassName.put(UserVerificationRequirement.class, (r) -> UserVerificationRequirement.REQUIRED); |
| 547 | + generatorByClassName.put(CredProtectAuthenticationExtensionsClientInput.CredProtect.class, (c) -> credProtect); |
| 548 | + generatorByClassName.put(CredProtectAuthenticationExtensionsClientInput.class, |
| 549 | + (c) -> new CredProtectAuthenticationExtensionsClientInput(credProtect)); |
| 550 | + generatorByClassName.put(ImmutableAuthenticationExtensionsClientInputs.class, (i) -> inputs); |
| 551 | + generatorByClassName.put(ImmutableAuthenticationExtensionsClientInput.class, |
| 552 | + (i) -> ImmutableAuthenticationExtensionsClientInput.credProps); |
| 553 | + generatorByClassName.put(Bytes.class, (b) -> id); |
| 554 | + generatorByClassName.put(PublicKeyCredentialDescriptor.class, (d) -> descriptor); |
| 555 | + // @formatter:off |
| 556 | + generatorByClassName.put(PublicKeyCredentialRequestOptions.class, (o) -> TestPublicKeyCredentialRequestOptions.create() |
| 557 | + .extensions(inputs) |
| 558 | + .allowCredentials(List.of(descriptor)) |
| 559 | + .build() |
| 560 | + ); |
| 561 | + // @formatter:on |
518 | 562 | } |
519 | 563 |
|
520 | 564 | @ParameterizedTest |
@@ -560,7 +604,7 @@ private static void collectTransientFieldNames(Set<String> transientFieldNames, |
560 | 604 |
|
561 | 605 | @ParameterizedTest |
562 | 606 | @MethodSource("getClassesToSerialize") |
563 | | - @Disabled("This method should only be used to serialize the classes once") |
| 607 | + // @Disabled("This method should only be used to serialize the classes once") |
564 | 608 | void serializeCurrentVersionClasses(Class<?> clazz) throws Exception { |
565 | 609 | Files.createDirectories(currentVersionFolder); |
566 | 610 | Path filePath = Paths.get(currentVersionFolder.toAbsolutePath() + "/" + clazz.getName() + ".serialized"); |
|
0 commit comments