Skip to content

Commit 66e33a7

Browse files
committed
Reduce minSuccessful count for tests of TPM additional properites
These were among the slowest tests (upwards of seconds of runtime), this will speed them up a bit.
1 parent 5283afc commit 66e33a7

File tree

1 file changed

+102
-92
lines changed

1 file changed

+102
-92
lines changed

webauthn-server-core/src/test/scala/com/yubico/webauthn/RelyingPartyRegistrationSpec.scala

Lines changed: 102 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,8 +2762,35 @@ class RelyingPartyRegistrationSpec
27622762

27632763
describe("Other requirements:") {
27642764
it("RSA keys must have the SIGN_ENCRYPT attribute.") {
2765-
forAll(Gen.chooseNum(0, Int.MaxValue.toLong * 2 + 1)) {
2766-
attributes: Long =>
2765+
forAll(
2766+
Gen.chooseNum(0, Int.MaxValue.toLong * 2 + 1),
2767+
minSuccessful(5),
2768+
) { attributes: Long =>
2769+
val testData = (RegistrationTestData.from _).tupled(
2770+
makeCred(
2771+
authDataAndKeypair = Some(
2772+
TestAuthenticator
2773+
.createAuthenticatorData(keyAlgorithm =
2774+
COSEAlgorithmIdentifier.RS256
2775+
)
2776+
),
2777+
attributes = Some(attributes & ~Attributes.SIGN_ENCRYPT),
2778+
)
2779+
)
2780+
val step = init(testData)
2781+
testData.alg should be(COSEAlgorithmIdentifier.RS256)
2782+
2783+
step.validations shouldBe a[Failure[_]]
2784+
step.tryNext shouldBe a[Failure[_]]
2785+
}
2786+
}
2787+
2788+
it("""RSA keys must have "symmetric" set to TPM_ALG_NULL""") {
2789+
forAll(
2790+
Gen.chooseNum(0, Short.MaxValue * 2 + 1),
2791+
minSuccessful(5),
2792+
) { symmetric: Int =>
2793+
whenever(symmetric != TPM_ALG_NULL) {
27672794
val testData = (RegistrationTestData.from _).tupled(
27682795
makeCred(
27692796
authDataAndKeypair = Some(
@@ -2772,71 +2799,76 @@ class RelyingPartyRegistrationSpec
27722799
COSEAlgorithmIdentifier.RS256
27732800
)
27742801
),
2775-
attributes =
2776-
Some(attributes & ~Attributes.SIGN_ENCRYPT),
2802+
symmetric = Some(symmetric),
27772803
)
27782804
)
27792805
val step = init(testData)
27802806
testData.alg should be(COSEAlgorithmIdentifier.RS256)
27812807

27822808
step.validations shouldBe a[Failure[_]]
27832809
step.tryNext shouldBe a[Failure[_]]
2810+
}
27842811
}
27852812
}
27862813

2787-
it("""RSA keys must have "symmetric" set to TPM_ALG_NULL""") {
2788-
forAll(Gen.chooseNum(0, Short.MaxValue * 2 + 1)) {
2789-
symmetric: Int =>
2790-
whenever(symmetric != TPM_ALG_NULL) {
2791-
val testData = (RegistrationTestData.from _).tupled(
2792-
makeCred(
2793-
authDataAndKeypair = Some(
2794-
TestAuthenticator
2795-
.createAuthenticatorData(keyAlgorithm =
2796-
COSEAlgorithmIdentifier.RS256
2797-
)
2798-
),
2799-
symmetric = Some(symmetric),
2800-
)
2814+
it("""RSA keys must have "scheme" set to TPM_ALG_RSASSA or TPM_ALG_NULL""") {
2815+
forAll(
2816+
Gen.chooseNum(0, Short.MaxValue * 2 + 1),
2817+
minSuccessful(5),
2818+
) { scheme: Int =>
2819+
whenever(
2820+
scheme != TpmRsaScheme.RSASSA && scheme != TPM_ALG_NULL
2821+
) {
2822+
val testData = (RegistrationTestData.from _).tupled(
2823+
makeCred(
2824+
authDataAndKeypair = Some(
2825+
TestAuthenticator
2826+
.createAuthenticatorData(keyAlgorithm =
2827+
COSEAlgorithmIdentifier.RS256
2828+
)
2829+
),
2830+
scheme = Some(scheme),
28012831
)
2802-
val step = init(testData)
2803-
testData.alg should be(COSEAlgorithmIdentifier.RS256)
2832+
)
2833+
val step = init(testData)
2834+
testData.alg should be(COSEAlgorithmIdentifier.RS256)
28042835

2805-
step.validations shouldBe a[Failure[_]]
2806-
step.tryNext shouldBe a[Failure[_]]
2807-
}
2836+
step.validations shouldBe a[Failure[_]]
2837+
step.tryNext shouldBe a[Failure[_]]
2838+
}
28082839
}
28092840
}
28102841

2811-
it("""RSA keys must have "scheme" set to TPM_ALG_RSASSA or TPM_ALG_NULL""") {
2812-
forAll(Gen.chooseNum(0, Short.MaxValue * 2 + 1)) {
2813-
scheme: Int =>
2814-
whenever(
2815-
scheme != TpmRsaScheme.RSASSA && scheme != TPM_ALG_NULL
2816-
) {
2817-
val testData = (RegistrationTestData.from _).tupled(
2818-
makeCred(
2819-
authDataAndKeypair = Some(
2820-
TestAuthenticator
2821-
.createAuthenticatorData(keyAlgorithm =
2822-
COSEAlgorithmIdentifier.RS256
2823-
)
2824-
),
2825-
scheme = Some(scheme),
2826-
)
2827-
)
2828-
val step = init(testData)
2829-
testData.alg should be(COSEAlgorithmIdentifier.RS256)
2842+
it("ECC keys must have the SIGN_ENCRYPT attribute.") {
2843+
forAll(
2844+
Gen.chooseNum(0, Int.MaxValue.toLong * 2 + 1),
2845+
minSuccessful(5),
2846+
) { attributes: Long =>
2847+
val testData = (RegistrationTestData.from _).tupled(
2848+
makeCred(
2849+
authDataAndKeypair = Some(
2850+
TestAuthenticator
2851+
.createAuthenticatorData(keyAlgorithm =
2852+
COSEAlgorithmIdentifier.ES256
2853+
)
2854+
),
2855+
attributes = Some(attributes & ~Attributes.SIGN_ENCRYPT),
2856+
)
2857+
)
2858+
val step = init(testData)
2859+
testData.alg should be(COSEAlgorithmIdentifier.ES256)
28302860

2831-
step.validations shouldBe a[Failure[_]]
2832-
step.tryNext shouldBe a[Failure[_]]
2833-
}
2861+
step.validations shouldBe a[Failure[_]]
2862+
step.tryNext shouldBe a[Failure[_]]
28342863
}
28352864
}
28362865

2837-
it("ECC keys must have the SIGN_ENCRYPT attribute.") {
2838-
forAll(Gen.chooseNum(0, Int.MaxValue.toLong * 2 + 1)) {
2839-
attributes: Long =>
2866+
it("""ECC keys must have "symmetric" set to TPM_ALG_NULL""") {
2867+
forAll(
2868+
Gen.chooseNum(0, Short.MaxValue * 2 + 1),
2869+
minSuccessful(5),
2870+
) { symmetric: Int =>
2871+
whenever(symmetric != TPM_ALG_NULL) {
28402872
val testData = (RegistrationTestData.from _).tupled(
28412873
makeCred(
28422874
authDataAndKeypair = Some(
@@ -2845,63 +2877,41 @@ class RelyingPartyRegistrationSpec
28452877
COSEAlgorithmIdentifier.ES256
28462878
)
28472879
),
2848-
attributes =
2849-
Some(attributes & ~Attributes.SIGN_ENCRYPT),
2880+
symmetric = Some(symmetric),
28502881
)
28512882
)
28522883
val step = init(testData)
28532884
testData.alg should be(COSEAlgorithmIdentifier.ES256)
28542885

28552886
step.validations shouldBe a[Failure[_]]
28562887
step.tryNext shouldBe a[Failure[_]]
2857-
}
2858-
}
2859-
2860-
it("""ECC keys must have "symmetric" set to TPM_ALG_NULL""") {
2861-
forAll(Gen.chooseNum(0, Short.MaxValue * 2 + 1)) {
2862-
symmetric: Int =>
2863-
whenever(symmetric != TPM_ALG_NULL) {
2864-
val testData = (RegistrationTestData.from _).tupled(
2865-
makeCred(
2866-
authDataAndKeypair = Some(
2867-
TestAuthenticator
2868-
.createAuthenticatorData(keyAlgorithm =
2869-
COSEAlgorithmIdentifier.ES256
2870-
)
2871-
),
2872-
symmetric = Some(symmetric),
2873-
)
2874-
)
2875-
val step = init(testData)
2876-
testData.alg should be(COSEAlgorithmIdentifier.ES256)
2877-
2878-
step.validations shouldBe a[Failure[_]]
2879-
step.tryNext shouldBe a[Failure[_]]
2880-
}
2888+
}
28812889
}
28822890
}
28832891

28842892
it("""ECC keys must have "scheme" set to TPM_ALG_NULL""") {
2885-
forAll(Gen.chooseNum(0, Short.MaxValue * 2 + 1)) {
2886-
scheme: Int =>
2887-
whenever(scheme != TPM_ALG_NULL) {
2888-
val testData = (RegistrationTestData.from _).tupled(
2889-
makeCred(
2890-
authDataAndKeypair = Some(
2891-
TestAuthenticator
2892-
.createAuthenticatorData(keyAlgorithm =
2893-
COSEAlgorithmIdentifier.ES256
2894-
)
2895-
),
2896-
scheme = Some(scheme),
2897-
)
2893+
forAll(
2894+
Gen.chooseNum(0, Short.MaxValue * 2 + 1),
2895+
minSuccessful(5),
2896+
) { scheme: Int =>
2897+
whenever(scheme != TPM_ALG_NULL) {
2898+
val testData = (RegistrationTestData.from _).tupled(
2899+
makeCred(
2900+
authDataAndKeypair = Some(
2901+
TestAuthenticator
2902+
.createAuthenticatorData(keyAlgorithm =
2903+
COSEAlgorithmIdentifier.ES256
2904+
)
2905+
),
2906+
scheme = Some(scheme),
28982907
)
2899-
val step = init(testData)
2900-
testData.alg should be(COSEAlgorithmIdentifier.ES256)
2908+
)
2909+
val step = init(testData)
2910+
testData.alg should be(COSEAlgorithmIdentifier.ES256)
29012911

2902-
step.validations shouldBe a[Failure[_]]
2903-
step.tryNext shouldBe a[Failure[_]]
2904-
}
2912+
step.validations shouldBe a[Failure[_]]
2913+
step.tryNext shouldBe a[Failure[_]]
2914+
}
29052915
}
29062916
}
29072917
}

0 commit comments

Comments
 (0)