Debian Codegraph @

addons/auth_totp_portal/static/tests/totp_portal.js

raw symbols SCIP
1 import { registry } from "@web/core/registry";
2 import { rpc } from "@web/core/network/rpc";
3
4 registry.category("web_tour.tours").add('totportal_tour_setup', {
5 url: '/my/security',
6 steps: () => [{
7 content: "Open totp wizard",
8 trigger: 'button#auth_totp_portal_enable',
9 run: "click",
10 }, {
11 content: "Check that we have to enter enhanced security mode",
12 trigger: ".modal div:contains(enter your password)",
13 }, {
14 content: "Input password",
15 trigger: '[name=password]',
16 run: "edit portal", // FIXME: better way to do this?
17 }, {
18 content: "Confirm",
19 trigger: "button:contains(Confirm Password)",
20 run: "click",
21 }, {
22 content: "Check the wizard has opened",
23 trigger: '.o_auth_totp_enable_2FA',
24 }, {
25 content: "Get secret from collapsed div",
26 trigger: 'a:contains("Cannot scan it?")',
27 },
28 {
29 trigger: `span[name="secret"]:hidden`,
30 async run(helpers) {
31 const secret = this.anchor.textContent;
32 const token = await rpc("/totphook", {
33 secret,
34 offset: 0,
35 });
36 await helpers.edit(token, 'input[name="code"]');
37 }
38 }, {
39 trigger: "button.btn-primary:contains(Activate)",
40 run: "click",
41 expectUnloadPage: true,
42 }, {
43 content: "Check that the button has changed",
44 trigger: 'button:contains(Disable two-factor authentication)',
45 }]});
46
47 registry.category("web_tour.tours").add('totportal_login_enabled', {
48 url: '/',
49 steps: () => [{
50 content: "check that we're on the login page or go to it",
51 isActive: ["body:not(:has(input#login))"],
52 trigger: "a:contains(Sign in)",
53 run: "click",
54 expectUnloadPage: true,
55 }, {
56 content: "input login",
57 trigger: 'input#login',
58 run: "edit portal",
59 }, {
60 content: 'input password',
61 trigger: 'input#password',
62 run: "edit portal",
63 }, {
64 content: "click da button",
65 trigger: 'button:contains("Log in")',
66 run: "click",
67 expectUnloadPage: true,
68 }, {
69 content: "expect totp screen",
70 trigger: 'label:contains(Authentication Code)',
71 run: "click",
72 }, {
73 content: "input code",
74 trigger: 'input[name=totp_token]',
75 run: async function (helpers) {
76 const token = await rpc('/totphook', { offset: 1 });
77 await helpers.edit(token);
78 }
79 }, {
80 trigger: "button:contains(Log in)",
81 run: "click",
82 expectUnloadPage: true,
83 }, {
84 content: "check we're logged in",
85 trigger: "h3:contains(My account)",
86 }, {
87 content: "go back to security",
88 trigger: "a:contains(Security)",
89 run: "click",
90 expectUnloadPage: true,
91 },{
92 content: "Open totp wizard",
93 trigger: 'button#auth_totp_portal_disable',
94 run: "click",
95 }, {
96 content: "Check that we have to enter enhanced security mode",
97 trigger: ".modal div:contains(enter your password)",
98 }, {
99 content: "Input password",
100 trigger: '[name=password]',
101 run: "edit portal",
102 }, {
103 content: "Confirm",
104 trigger: "button:contains(Confirm Password)",
105 run: "click",
106 expectUnloadPage: true,
107 }, {
108 content: "Check that the button has changed",
109 trigger: 'button:contains(Enable two-factor authentication)',
110 }]});
111
112 registry.category("web_tour.tours").add('totportal_login_disabled', {
113 url: '/',
114 steps: () => [{
115 content: "check that we're on the login page or go to it",
116 isActive: ["body:not(:has(input#login))"],
117 trigger: "a:contains(Sign in)",
118 run: "click",
119 expectUnloadPage: true,
120 }, {
121 content: "input login",
122 trigger: 'input#login',
123 run: "edit portal",
124 }, {
125 content: 'input password',
126 trigger: 'input#password',
127 run: "edit portal",
128 }, {
129 content: "click da button",
130 trigger: 'button:contains("Log in")',
131 run: "click",
132 expectUnloadPage: true,
133 }, {
134 content: "check we're logged in",
135 trigger: "h3:contains(My account)",
136 }]});