use of com.webauthn4j.data.extension.HMACGetSecretOutput in project webauthn4j by webauthn4j.
the class AuthenticationExtensionsClientOutputsTest method authentication_variant_test.
@SuppressWarnings("java:S5961")
@Test
void authentication_variant_test() {
UvmEntries uvm = new UvmEntries(Collections.singletonList(new UvmEntry(UserVerificationMethod.FINGERPRINT_INTERNAL, KeyProtectionType.SOFTWARE, MatcherProtectionType.ON_CHIP)));
AuthenticationExtensionsClientOutputs.BuilderForAuthentication builder = new AuthenticationExtensionsClientOutputs.BuilderForAuthentication();
builder.setAppid(true);
builder.setUvm(uvm);
builder.setHMACGetSecret(new HMACGetSecretOutput(new byte[32], new byte[32]));
builder.set("unknown", "data");
AuthenticationExtensionsClientOutputs<AuthenticationExtensionClientOutput> target = builder.build();
assertThat(target.getKeys()).containsExactlyInAnyOrder("appid", "uvm", "hmacGetSecret", "unknown");
assertThat(target.getAppid()).isTrue();
assertThat(target.getUvm()).isEqualTo(uvm);
assertThat(target.getCredProps()).isNull();
assertThat(target.getHMACCreateSecret()).isNull();
assertThat(target.getHMACGetSecret()).isEqualTo(new HMACGetSecretOutput(new byte[32], new byte[32]));
assertThat(target.getUnknownKeys()).containsExactly("unknown");
assertThat((Boolean) target.getValue("appid")).isTrue();
assertThat(target.getValue("uvm")).isEqualTo(uvm);
assertThat(target.getValue("credProps")).isNull();
assertThat((Boolean) target.getValue("hmacCreateSecret")).isNull();
assertThat(target.getValue("hmacGetSecret")).isEqualTo(new HMACGetSecretOutput(new byte[32], new byte[32]));
assertThat(target.getValue("unknown")).isEqualTo("data");
assertThat(target.getValue("invalid")).isNull();
assertThat(target.getExtension(FIDOAppIDExtensionClientOutput.class)).isNotNull();
assertThat(target.getExtension(FIDOAppIDExtensionClientOutput.class).getIdentifier()).isEqualTo("appid");
assertThat(target.getExtension(FIDOAppIDExtensionClientOutput.class).getAppid()).isTrue();
assertThat(target.getExtension(UserVerificationMethodExtensionClientOutput.class)).isNotNull();
assertThat(target.getExtension(UserVerificationMethodExtensionClientOutput.class).getIdentifier()).isEqualTo("uvm");
assertThat(target.getExtension(UserVerificationMethodExtensionClientOutput.class).getUvm()).isEqualTo(uvm);
HMACSecretAuthenticationExtensionClientOutput hmacSecretAuthenticationExtensionClientOutput = target.getExtension(HMACSecretAuthenticationExtensionClientOutput.class);
assertThat(hmacSecretAuthenticationExtensionClientOutput).isNotNull();
assertThat(hmacSecretAuthenticationExtensionClientOutput.getIdentifier()).isEqualTo("hmac-secret");
assertThat(hmacSecretAuthenticationExtensionClientOutput.getValue()).isEqualTo(new HMACGetSecretOutput(new byte[32], new byte[32]));
assertThatThrownBy(() -> hmacSecretAuthenticationExtensionClientOutput.getValue("hmac-secret")).isInstanceOf(IllegalArgumentException.class);
assertThatThrownBy(() -> hmacSecretAuthenticationExtensionClientOutput.getValue("hmacCreateSecret")).isInstanceOf(IllegalArgumentException.class);
assertThat(hmacSecretAuthenticationExtensionClientOutput.getValue("hmacGetSecret")).isEqualTo(new HMACGetSecretOutput(new byte[32], new byte[32]));
}
use of com.webauthn4j.data.extension.HMACGetSecretOutput in project webauthn4j by webauthn4j.
the class AuthenticationExtensionsClientOutputsTest method equals_hashCode_test.
@Test
void equals_hashCode_test() {
UvmEntries uvm = new UvmEntries(Collections.singletonList(new UvmEntry(UserVerificationMethod.FINGERPRINT_INTERNAL, KeyProtectionType.SOFTWARE, MatcherProtectionType.ON_CHIP)));
AuthenticationExtensionsClientOutputs.BuilderForAuthentication builder1 = new AuthenticationExtensionsClientOutputs.BuilderForAuthentication();
builder1.setAppid(true);
builder1.setUvm(uvm);
builder1.setHMACGetSecret(new HMACGetSecretOutput(new byte[32], new byte[32]));
AuthenticationExtensionsClientOutputs<AuthenticationExtensionClientOutput> instance1 = builder1.build();
AuthenticationExtensionsClientOutputs.BuilderForAuthentication builder2 = new AuthenticationExtensionsClientOutputs.BuilderForAuthentication();
builder2.setAppid(true);
builder2.setUvm(uvm);
builder2.setHMACGetSecret(new HMACGetSecretOutput(new byte[32], new byte[32]));
AuthenticationExtensionsClientOutputs<AuthenticationExtensionClientOutput> instance2 = builder2.build();
assertThat(instance1).isEqualTo(instance2).hasSameHashCodeAs(instance2);
}
Aggregations