Skip to content

Commit 80e09c7

Browse files
committed
fix more tests
1 parent ae1dd47 commit 80e09c7

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

src/internet_identity/tests/integration/v2_api/identity_register.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod dynamic_captcha;
22

33
use crate::v2_api::authn_method_test_helpers::{
44
create_identity_with_authn_method, create_identity_with_authn_method_and_name,
5-
test_authn_method,
5+
sample_webauthn_authn_method, test_authn_method,
66
};
77
use candid::Principal;
88
use canister_tests::api::internet_identity::{api_v2, get_anchor_info};
@@ -36,9 +36,10 @@ fn should_register_new_identity() {
3636
fn should_register_multiple_identities() {
3737
let env = env();
3838
let canister_id = install_ii_with_archive(&env, None, None);
39-
let authn_method = test_authn_method();
40-
let identity_number_1 = create_identity_with_authn_method(&env, canister_id, &authn_method);
41-
let identity_number_2 = create_identity_with_authn_method(&env, canister_id, &authn_method);
39+
let identity_number_1 =
40+
create_identity_with_authn_method(&env, canister_id, &sample_webauthn_authn_method(0));
41+
let identity_number_2 =
42+
create_identity_with_authn_method(&env, canister_id, &sample_webauthn_authn_method(1));
4243

4344
assert_ne!(identity_number_1, identity_number_2);
4445
}
@@ -88,9 +89,8 @@ fn should_not_exceed_configured_identity_range() {
8889
let canister_id =
8990
install_ii_canister_with_arg(&env, II_WASM.clone(), arg_with_anchor_range((42, 44)));
9091

91-
let authn_method = test_authn_method();
92-
create_identity_with_authn_method(&env, canister_id, &authn_method);
93-
create_identity_with_authn_method(&env, canister_id, &authn_method);
92+
create_identity_with_authn_method(&env, canister_id, &sample_webauthn_authn_method(0));
93+
create_identity_with_authn_method(&env, canister_id, &sample_webauthn_authn_method(1));
9494

9595
let flow_principal = test_principal(0);
9696
api_v2::identity_registration_start(&env, canister_id, flow_principal)
@@ -105,7 +105,7 @@ fn should_not_exceed_configured_identity_range() {
105105
&env,
106106
canister_id,
107107
flow_principal,
108-
&authn_method,
108+
&sample_webauthn_authn_method(2),
109109
None,
110110
)
111111
.expect("API call failed");

src/internet_identity/tests/integration/v2_api/identity_register/dynamic_captcha.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::v2_api::authn_method_test_helpers::{
2-
create_identity_with_authn_method, test_authn_method,
2+
create_identity_with_authn_method, sample_webauthn_authn_method, test_authn_method,
33
};
44
use canister_tests::api::internet_identity::api_v2;
55
use canister_tests::framework::{
@@ -38,11 +38,14 @@ fn should_require_captcha_above_threshold_rate() {
3838
let env = env();
3939
let canister_id =
4040
install_ii_canister_with_arg(&env, II_WASM.clone(), arg_with_dynamic_captcha());
41-
let authn_method = test_authn_method();
4241

4342
// initialize a base rate of one registration every 4 seconds for 100 seconds (reference rate)
44-
for _ in 0..25 {
45-
create_identity_with_authn_method(&env, canister_id, &authn_method);
43+
for i in 0..25 {
44+
create_identity_with_authn_method(
45+
&env,
46+
canister_id,
47+
&sample_webauthn_authn_method(i as u8),
48+
);
4649
env.advance_time(Duration::from_secs(4))
4750
}
4851

@@ -60,7 +63,7 @@ fn should_require_captcha_above_threshold_rate() {
6063
&env,
6164
canister_id,
6265
flow_principal,
63-
&authn_method,
66+
&sample_webauthn_authn_method((25 + i) as u8),
6467
None,
6568
)
6669
.expect("API call failed")

src/internet_identity/tests/integration/v2_api/passkey_aaguid.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,19 @@ fn should_enforce_unique_passkey_pubkeys_in_registration_mode_flows() -> Result<
606606
let b0_initial = webauthn_authn_method(p1.clone(), test_credential_id(11).unwrap());
607607
let identity_b0 = create_identity_with_authn_method(&env, canister_id, &b0_initial);
608608

609+
// Enter registration mode for identity B0 (needed for both checks below).
610+
let registration_mode_id = "0eZr5".to_string();
611+
let intermediate_sender = Principal::self_authenticating([42; 32]);
612+
613+
canister_tests::api::internet_identity::api_v2::authn_method_registration_mode_enter(
614+
&env,
615+
canister_id,
616+
b0_initial.principal(),
617+
identity_b0,
618+
Some(registration_mode_id.clone()),
619+
)?
620+
.unwrap();
621+
609622
// 1. authn_method_register must reject registering a passkey whose pubkey is already used.
610623
let a1_same_p0 = webauthn_authn_method(p0.clone(), test_credential_id(12).unwrap());
611624
let result_register_conflict =
@@ -621,18 +634,6 @@ fn should_enforce_unique_passkey_pubkeys_in_registration_mode_flows() -> Result<
621634
);
622635

623636
// 2. authn_method_registration_mode_exit must reject adding a passkey whose pubkey is already used.
624-
let registration_mode_id = "0eZr5".to_string();
625-
let intermediate_sender = Principal::self_authenticating([42; 32]);
626-
627-
// Enter registration mode for identity B0.
628-
canister_tests::api::internet_identity::api_v2::authn_method_registration_mode_enter(
629-
&env,
630-
canister_id,
631-
b0_initial.principal(),
632-
identity_b0,
633-
Some(registration_mode_id.clone()),
634-
)?
635-
.unwrap();
636637

637638
// Create a session for B0 (this stores a confirmed session principal).
638639
let AuthnMethodConfirmationCode {

0 commit comments

Comments
 (0)