Debian Codegraph @

addons/auth_passkey_portal/static/tests/tours/test_passkey_portal.js

raw symbols SCIP
1 import { registry } from "@web/core/registry";
2 import { patch } from "@web/core/utils/patch";
3 import * as passkeyLib from "@auth_passkey/../lib/simplewebauthn";
4
5 let unpatchPasskeyRegistrationPortal;
6
7 registry.category("web_tour.tours").add("passkeys_portal_create", {
8 url: "/my/security",
9 steps: () => [
10 {
11 content: "Ensure there are no passkeys already",
12 trigger: 'button:contains("Add Passkey")',
13 run: () => {
14 const amount = document.querySelectorAll(".o_passkey_portal_entry").length;
15 if (amount != 0) {
16 throw Error("Amount of Passkeys must be 0");
17 }
18 },
19 }, {
20 content: "Add a Passkey",
21 trigger: 'button:contains("Add Passkey")',
22 run: "click",
23 }, {
24 content: "Check that we have to enter enhanced security mode",
25 trigger: "form strong:contains(Please enter your password to confirm you own this account)",
26 }, {
27 content: "Input password",
28 trigger: "form input[name=password]",
29 run: "edit passkey_portal",
30 }, {
31 content: "Confirm",
32 trigger: ".modal-footer button:contains(Confirm Password)",
33 run: "click",
34 }, {
35 content: "Ready to create Passkey",
36 trigger: ".modal-title:contains(Create Passkey)",
37 }, {
38 content: "Input passkey name",
39 trigger: 'input[name="keyname"]',
40 run: "edit test_passkey_one",
41 }, {
42 content: "Override startRegistration",
43 trigger: "body",
44 run: () => {
45 unpatchPasskeyRegistrationPortal = patch(passkeyLib, {
46 async startRegistration() {
47 return {
48 // test-yubikey
49 "id": "L2p6jvcWuCMTRmkZHKqqvQbz0Dhk3JbJOx1F8ci99nSNjlfx3Z7nkigMdUACLggB",
50 "rawId": "L2p6jvcWuCMTRmkZHKqqvQbz0Dhk3JbJOx1F8ci99nSNjlfx3Z7nkigMdUACLggB",
51 "response": {
52 "attestationObject": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjCSZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2PFAAAAAgAAAAAAAAAAAAAAAAAAAAAAMC9qeo73FrgjE0ZpGRyqqr0G89A4ZNyWyTsdRfHIvfZ0jY5X8d2e55IoDHVAAi4IAaUBAgMmIAEhWCAvanqO9xa4IxNGaRkcMSyBudC-JDZYY9gyMqknP2IkUiJYINqumy9viKCeo_xpFU3XzyssfEReXvMM1_fmZN-wMpDPoWtjcmVkUHJvdGVjdAI",
53 "clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoiVW9hNk01akVQN0kzVG95SzlRQTB2ZjhJY3NlemZlSmswcmdzMXBMVVdyTWdGOXZkMC03RHY1aVYzeFc3cjcwLVlxa3dlUlhoQUNtRFBtaEhLdEFJZVEiLCJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwNjkiLCJjcm9zc09yaWdpbiI6ZmFsc2V9",
54 "transports": [
55 "nfc",
56 "usb",
57 ],
58 "publicKeyAlgorithm": -7,
59 "publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEL2p6jvcWuCMTRmkZHDEsgbnQviQ2WGPYMjKpJz9iJFLarpsvb4ignqP8aRVN188rLHxEXl7zDNf35mTfsDKQzw",
60 "authenticatorData": "SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2PFAAAAAgAAAAAAAAAAAAAAAAAAAAAAMC9qeo73FrgjE0ZpGRyqqr0G89A4ZNyWyTsdRfHIvfZ0jY5X8d2e55IoDHVAAi4IAaUBAgMmIAEhWCAvanqO9xa4IxNGaRkcMSyBudC-JDZYY9gyMqknP2IkUiJYINqumy9viKCeo_xpFU3XzyssfEReXvMM1_fmZN-wMpDPoWtjcmVkUHJvdGVjdAI",
61 },
62 "type": "public-key",
63 "clientExtensionResults": {},
64 "authenticatorAttachment": "cross-platform",
65 };
66 },
67 });
68 },
69 }, {
70 content: "Click the Create button",
71 trigger: ".modal-content button:contains(Create)",
72 run: "click",
73 expectUnloadPage: true,
74 }, {
75 content: "Return startRegistration to original state",
76 trigger: "body",
77 run: () => {
78 if (unpatchPasskeyRegistrationPortal) {
79 unpatchPasskeyRegistrationPortal();
80 }
81 },
82 }, {
83 content: "Ensure there is one passkey",
84 trigger: ".o_passkey_name",
85 run: () => {
86 const amount = document.querySelectorAll(".o_passkey_portal_entry").length;
87 if (amount != 1) {
88 throw Error("Amount of Passkeys must be 1");
89 }
90 },
91 },
92 ],
93 });
94
95 registry.category("web_tour.tours").add("passkeys_portal_rename", {
96 url: "/my/security",
97 steps: () => [
98 {
99 content: "Ensure there is one passkey",
100 trigger: 'button:contains("Add Passkey")',
101 run: () => {
102 const amount = document.querySelectorAll(".o_passkey_portal_entry").length;
103 if (amount != 1) {
104 throw Error("Amount of Passkeys must be 1");
105 }
106 },
107 }, {
108 content: "Click rename",
109 trigger: '.o_passkey_portal_rename',
110 run: "click",
111 }, {
112 content: "Input passkey name",
113 trigger: 'input[name="keyname"]',
114 run: "edit edited_key",
115 }, {
116 content: "Confirm the rename",
117 trigger: ".modal-content button:contains(Rename)",
118 run: "click",
119 expectUnloadPage: true,
120 }, {
121 content: "Ensure the rename occurred",
122 trigger: ".o_passkey_name:contains(edited_key)",
123 },
124 ],
125 });
126
127 registry.category("web_tour.tours").add("passkeys_portal_delete", {
128 url: "/my/security",
129 steps: () => [
130 {
131 content: "Ensure there is one passkey",
132 trigger: 'button:contains("Add Passkey")',
133 run: () => {
134 const amount = document.querySelectorAll(".o_passkey_portal_entry").length;
135 if (amount != 1) {
136 throw Error("Amount of Passkeys must be 1");
137 }
138 },
139 }, {
140 content: "Click delete",
141 trigger: '.o_passkey_portal_delete',
142 run: "click",
143 }, {
144 content: "Check that we have to enter enhanced security mode",
145 trigger: "form strong:contains(Please enter your password to confirm you own this account)",
146 }, {
147 content: "Input password",
148 trigger: "form input[name=password]",
149 run: "edit passkey_portal",
150 }, {
151 content: "Confirm",
152 trigger: ".modal-footer button:contains(Confirm Password)",
153 run: "click",
154 expectUnloadPage: true,
155 }, {
156 content: "Ensure there are no more passkeys",
157 trigger: 'button:contains("Add Passkey")',
158 run: () => {
159 const amount = document.querySelectorAll(".o_passkey_portal_entry").length;
160 if (amount != 0) {
161 throw Error("Amount of Passkeys must be 0");
162 }
163 },
164 },
165 ],
166 });