Functional Weave
Code in Rust

auth.account-link@1.0.0

vectors.json

6,074 bytes · view raw

[
  {"name": "a provider identity already linked signs in to its account, whatever the email now says", "args": [{"provider": "google", "subject": "1078", "email": "new-address@Example.COM", "emailVerified": false}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}], [{"provider": "google", "subject": "1078", "accountId": "acc_1"}]], "expect": {"action": "sign-in", "reason": "existing_link", "accountId": "acc_1", "email": "new-address@example.com"}},
  {"name": "a link to an account that no longer exists is refused, naming the account", "args": [{"provider": "github", "subject": "583231", "email": "ada@example.com", "emailVerified": true}, [], [{"provider": "github", "subject": "583231", "accountId": "acc_deleted"}]], "expect": {"action": "refuse", "reason": "linked_account_missing", "accountId": "acc_deleted", "email": "ada@example.com"}},
  {"name": "a verified provider email matching one verified account links to it (domain case ignored)", "args": [{"provider": "google", "subject": "1078", "email": " ada@EXAMPLE.com ", "emailVerified": true}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}, {"id": "acc_2", "email": "grace@example.com", "emailVerified": true}], []], "expect": {"action": "link", "reason": "verified_email_match", "accountId": "acc_1", "email": "ada@example.com"}},
  {"name": "a verified email that matches no account creates one", "args": [{"provider": "microsoft", "subject": "00000000-0000-0000-66f3-3332eca7ea81", "email": "grace@example.org", "emailVerified": true}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}], []], "expect": {"action": "create", "reason": "new_account", "accountId": null, "email": "grace@example.org"}},
  {"name": "an unverified email that matches no account must be verified by the app before creating", "args": [{"provider": "github", "subject": "99", "email": "grace@example.org", "emailVerified": false}, [], []], "expect": {"action": "require-verification", "reason": "unverified_new_email", "accountId": null, "email": "grace@example.org"}},
  {"name": "an unverified provider email never links to an existing account", "args": [{"provider": "github", "subject": "99", "email": "ada@example.com", "emailVerified": false}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}], []], "expect": {"action": "refuse", "reason": "unverified_email", "accountId": "acc_1", "email": "ada@example.com"}},
  {"name": "no email from the provider is refused", "args": [{"provider": "github", "subject": "99", "email": null, "emailVerified": false}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}], []], "expect": {"action": "refuse", "reason": "no_email", "accountId": null, "email": null}},
  {"name": "an email that is not an address counts as none", "args": [{"provider": "github", "subject": "99", "email": "not an email", "emailVerified": true}, [], []], "expect": {"action": "refuse", "reason": "no_email", "accountId": null, "email": null}},
  {"name": "the account already holds another identity from the same provider", "args": [{"provider": "google", "subject": "2001", "email": "ada@example.com", "emailVerified": true}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}], [{"provider": "google", "subject": "1078", "accountId": "acc_1"}, {"provider": "github", "subject": "583231", "accountId": "acc_1"}]], "expect": {"action": "refuse", "reason": "provider_already_linked", "accountId": "acc_1", "email": "ada@example.com"}},
  {"name": "another provider already linked to the account does not stop linking this one", "args": [{"provider": "google", "subject": "1078", "email": "ada@example.com", "emailVerified": true}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}], [{"provider": "github", "subject": "583231", "accountId": "acc_1"}]], "expect": {"action": "link", "reason": "verified_email_match", "accountId": "acc_1", "email": "ada@example.com"}},
  {"name": "an account whose own email was never verified must be verified first (pre-account hijacking)", "args": [{"provider": "google", "subject": "1078", "email": "ada@example.com", "emailVerified": true}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": false}], []], "expect": {"action": "require-verification", "reason": "account_email_unverified", "accountId": "acc_1", "email": "ada@example.com"}},
  {"name": "two accounts sharing the email is ambiguous and refused", "args": [{"provider": "google", "subject": "1078", "email": "ada@example.com", "emailVerified": true}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}, {"id": "acc_7", "email": "ada@EXAMPLE.COM", "emailVerified": false}], []], "expect": {"action": "refuse", "reason": "ambiguous_email", "accountId": null, "email": "ada@example.com"}},
  {"name": "the local part keeps its case, as auth.normalise-email stores it, so Ada@ is another address", "args": [{"provider": "google", "subject": "1078", "email": "Ada@example.com", "emailVerified": true}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}], []], "expect": {"action": "create", "reason": "new_account", "accountId": null, "email": "Ada@example.com"}},
  {"name": "a link with the same subject from another provider is not this identity", "args": [{"provider": "google", "subject": "583231", "email": "ada@example.com", "emailVerified": true}, [{"id": "acc_1", "email": "ada@example.com", "emailVerified": true}], [{"provider": "github", "subject": "583231", "accountId": "acc_1"}]], "expect": {"action": "link", "reason": "verified_email_match", "accountId": "acc_1", "email": "ada@example.com"}},
  {"name": "an empty provider is an error", "args": [{"provider": "", "subject": "1078", "email": "ada@example.com", "emailVerified": true}, [], []], "expectError": "identity.provider must be a non-empty string"},
  {"name": "an empty subject is an error", "args": [{"provider": "google", "subject": "", "email": "ada@example.com", "emailVerified": true}, [], []], "expectError": "identity.subject must be a non-empty string"}
]