summaryrefslogtreecommitdiff
path: root/addons/auth_totp_portal/static/tests
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/auth_totp_portal/static/tests
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/auth_totp_portal/static/tests')
-rw-r--r--addons/auth_totp_portal/static/tests/totp_portal.js124
1 files changed, 124 insertions, 0 deletions
diff --git a/addons/auth_totp_portal/static/tests/totp_portal.js b/addons/auth_totp_portal/static/tests/totp_portal.js
new file mode 100644
index 00000000..6424647a
--- /dev/null
+++ b/addons/auth_totp_portal/static/tests/totp_portal.js
@@ -0,0 +1,124 @@
+odoo.define('auth_totp_portal.tours', function(require) {
+"use strict";
+
+const tour = require('web_tour.tour');
+const ajax = require('web.ajax');
+
+tour.register('totportal_tour_setup', {
+ test: true,
+ url: '/my/security'
+}, [{
+ content: "Open totp wizard",
+ trigger: 'button#auth_totp_portal_enable',
+}, {
+ content: "Check that we have to enter enhanced security mode",
+ trigger: 'div:contains("confirm your password")',
+ run: () => {},
+}, {
+ content: "Input password",
+ trigger: '[name=password]',
+ run: 'text portal', // FIXME: better way to do this?
+}, {
+ content: "Confirm",
+ trigger: "button:contains(Confirm Password)",
+}, {
+ content: "Check the wizard has opened",
+ trigger: 'div:contains("Scan the image below")',
+ run: () => {}
+}, {
+ content: "Get secret from collapsed div",
+ trigger: 'a:contains("show the code")',
+ run: async function(helpers) {
+ const secret = this.$anchor.closest('div').find('code').text();
+ const token = await ajax.jsonRpc('/totphook', 'call', {
+ secret
+ });
+ helpers._text(helpers._get_action_values('input[name=code]'), token);
+ helpers._click(helpers._get_action_values('button.btn-primary:contains(Enable)'));
+ }
+}, {
+ content: "Check that the button has changed",
+ trigger: 'button:contains(Disable two-factor authentication)',
+ run: () => {}
+}]);
+
+tour.register('totportal_login_enabled', {
+ test: true,
+ url: '/'
+}, [{
+ content: "check that we're on the login page or go to it",
+ trigger: 'input#login, a:contains(Sign in)'
+}, {
+ content: "input login",
+ trigger: 'input#login',
+ run: 'text portal',
+}, {
+ content: 'input password',
+ trigger: 'input#password',
+ run: 'text portal',
+}, {
+ content: "click da button",
+ trigger: 'button:contains("Log in")',
+}, {
+ content: "expect totp screen",
+ trigger: 'label:contains(Authentication Code)',
+}, {
+ content: "input code",
+ trigger: 'input[name=totp_token]',
+ run: async function (helpers) {
+ const token = await ajax.jsonRpc('/totphook', 'call', {});
+ helpers._text(helpers._get_action_values(), token);
+ // FIXME: is there a way to put the button as its own step trigger without
+ // the tour straight blowing through and not waiting for this?
+ helpers._click(helpers._get_action_values('button:contains("Verify")'));
+ }
+}, {
+ content: "check we're logged in",
+ trigger: "h3:contains(Documents)",
+ run: () => {}
+}, {
+ content: "go back to security",
+ trigger: "a:contains(Security)",
+},{
+ content: "Open totp wizard",
+ trigger: 'button#auth_totp_portal_disable',
+}, {
+ content: "Check that we have to enter enhanced security mode",
+ trigger: 'div:contains("confirm your password")',
+ run: () => {},
+}, {
+ content: "Input password",
+ trigger: '[name=password]',
+ run: 'text portal', // FIXME: better way to do this?
+}, {
+ content: "Confirm",
+ trigger: "button:contains(Confirm Password)",
+}, {
+ content: "Check that the button has changed",
+ trigger: 'button:contains(Enable two-factor authentication)',
+ run: () => {}
+}]);
+
+tour.register('totportal_login_disabled', {
+ test: true,
+ url: '/'
+}, [{
+ content: "check that we're on the login page or go to it",
+ trigger: 'input#login, a:contains(Sign in)'
+}, {
+ content: "input login",
+ trigger: 'input#login',
+ run: 'text portal',
+}, {
+ content: 'input password',
+ trigger: 'input#password',
+ run: 'text portal',
+}, {
+ content: "click da button",
+ trigger: 'button:contains("Log in")',
+}, {
+ content: "check we're logged in",
+ trigger: "h3:contains(Documents)",
+ run: () => {}
+}]);
+});