dceky 1.0.23 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cypress/e2e/profile-test.cy.ts +1 -1
- package/lib/src/commands/handleHarvardKey.js +36 -33
- package/lib/src/commands/handleHarvardKey.js.map +1 -1
- package/lib/src/commands/launchAs.js +70 -68
- package/lib/src/commands/launchAs.js.map +1 -1
- package/lib/src/commands/logIntoPorta.js +46 -43
- package/lib/src/commands/logIntoPorta.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/handleHarvardKey.ts +41 -38
- package/src/commands/launchAs.ts +90 -88
- package/src/commands/logIntoPorta.ts +61 -57
- package/lib/commands/assertDoesNotHaveClass.d.ts +0 -18
- package/lib/commands/assertDoesNotHaveClass.js +0 -17
- package/lib/commands/assertDoesNotHaveClass.js.map +0 -1
- package/lib/commands/assertHasClass.d.ts +0 -18
- package/lib/commands/assertHasClass.js +0 -17
- package/lib/commands/assertHasClass.js.map +0 -1
- package/lib/commands/assertNumElements.d.ts +0 -18
- package/lib/commands/assertNumElements.js +0 -17
- package/lib/commands/assertNumElements.js.map +0 -1
- package/lib/commands/clickWithRetry.d.ts +0 -19
- package/lib/commands/clickWithRetry.js +0 -29
- package/lib/commands/clickWithRetry.js.map +0 -1
- package/lib/commands/genTextOfLength.d.ts +0 -20
- package/lib/commands/genTextOfLength.js +0 -20
- package/lib/commands/genTextOfLength.js.map +0 -1
- package/lib/commands/getAttribute.d.ts +0 -20
- package/lib/commands/getAttribute.js +0 -22
- package/lib/commands/getAttribute.js.map +0 -1
- package/lib/commands/getClassName.d.ts +0 -15
- package/lib/commands/getClassName.js +0 -21
- package/lib/commands/getClassName.js.map +0 -1
- package/lib/commands/getCurrentDateInfo.d.ts +0 -21
- package/lib/commands/getCurrentDateInfo.js +0 -25
- package/lib/commands/getCurrentDateInfo.js.map +0 -1
- package/lib/commands/getId.d.ts +0 -15
- package/lib/commands/getId.js +0 -21
- package/lib/commands/getId.js.map +0 -1
- package/lib/commands/getNumElements.d.ts +0 -14
- package/lib/commands/getNumElements.js +0 -19
- package/lib/commands/getNumElements.js.map +0 -1
- package/lib/commands/getSpecialChars.d.ts +0 -14
- package/lib/commands/getSpecialChars.js +0 -16
- package/lib/commands/getSpecialChars.js.map +0 -1
- package/lib/commands/getTitle.d.ts +0 -13
- package/lib/commands/getTitle.js +0 -20
- package/lib/commands/getTitle.js.map +0 -1
- package/lib/commands/handleHarvardKey.d.ts +0 -18
- package/lib/commands/handleHarvardKey.js +0 -56
- package/lib/commands/handleHarvardKey.js.map +0 -1
- package/lib/commands/handleHarvardKey2.d.ts +0 -14
- package/lib/commands/handleHarvardKey2.js +0 -88
- package/lib/commands/handleHarvardKey2.js.map +0 -1
- package/lib/commands/launchAs.d.ts +0 -20
- package/lib/commands/launchAs.js +0 -60
- package/lib/commands/launchAs.js.map +0 -1
- package/lib/commands/launchLTIUsingToken.d.ts +0 -19
- package/lib/commands/launchLTIUsingToken.js +0 -74
- package/lib/commands/launchLTIUsingToken.js.map +0 -1
- package/lib/commands/listSelectLabels.d.ts +0 -15
- package/lib/commands/listSelectLabels.js +0 -24
- package/lib/commands/listSelectLabels.js.map +0 -1
- package/lib/commands/listSelectValues.d.ts +0 -15
- package/lib/commands/listSelectValues.js +0 -26
- package/lib/commands/listSelectValues.js.map +0 -1
- package/lib/commands/navigateToHref.d.ts +0 -19
- package/lib/commands/navigateToHref.js +0 -23
- package/lib/commands/navigateToHref.js.map +0 -1
- package/lib/commands/padWithZeros.d.ts +0 -20
- package/lib/commands/padWithZeros.js +0 -24
- package/lib/commands/padWithZeros.js.map +0 -1
- package/lib/commands/runScript.d.ts +0 -16
- package/lib/commands/runScript.js +0 -25
- package/lib/commands/runScript.js.map +0 -1
- package/lib/commands/typeInto.d.ts +0 -20
- package/lib/commands/typeInto.js +0 -28
- package/lib/commands/typeInto.js.map +0 -1
- package/lib/commands/uniquify.d.ts +0 -15
- package/lib/commands/uniquify.js +0 -25
- package/lib/commands/uniquify.js.map +0 -1
- package/lib/commands/visitCanvasEndpoint.d.ts +0 -27
- package/lib/commands/visitCanvasEndpoint.js +0 -35
- package/lib/commands/visitCanvasEndpoint.js.map +0 -1
- package/lib/commands/visitCanvasGETEndpoint.d.ts +0 -20
- package/lib/commands/visitCanvasGETEndpoint.js +0 -26
- package/lib/commands/visitCanvasGETEndpoint.js.map +0 -1
- package/lib/commands/waitForAtLeastOneElementPresent.d.ts +0 -23
- package/lib/commands/waitForAtLeastOneElementPresent.js +0 -27
- package/lib/commands/waitForAtLeastOneElementPresent.js.map +0 -1
- package/lib/commands/waitForElementVisible.d.ts +0 -14
- package/lib/commands/waitForElementVisible.js +0 -20
- package/lib/commands/waitForElementVisible.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/init.d.ts +0 -6
- package/lib/init.js +0 -69
- package/lib/init.js.map +0 -1
- package/lib/postinstall/helpers/exec.d.ts +0 -8
- package/lib/postinstall/helpers/exec.js +0 -18
- package/lib/postinstall/helpers/exec.js.map +0 -1
- package/lib/setup/checkRequiredFiles.d.ts +0 -6
- package/lib/setup/checkRequiredFiles.js +0 -60
- package/lib/setup/checkRequiredFiles.js.map +0 -1
- package/lib/setup/genEmptyGlobalFile.d.ts +0 -7
- package/lib/setup/genEmptyGlobalFile.js +0 -41
- package/lib/setup/genEmptyGlobalFile.js.map +0 -1
- package/lib/src/commands/launchLTIUsingToken.d.ts +0 -21
- package/lib/src/commands/launchLTIUsingToken.js +0 -76
- package/lib/src/commands/launchLTIUsingToken.js.map +0 -1
- package/lib/src/commands/visitCanvasGETEndpoint.d.ts +0 -20
- package/lib/src/commands/visitCanvasGETEndpoint.js +0 -26
- package/lib/src/commands/visitCanvasGETEndpoint.js.map +0 -1
- package/lib/src/init.d.ts +0 -6
- package/lib/src/init.js +0 -71
- package/lib/src/init.js.map +0 -1
- package/lib/src/node.d.ts +0 -2
- package/lib/src/node.js +0 -10
- package/lib/src/node.js.map +0 -1
|
@@ -7,41 +7,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
var handleHarvardKey = function () {
|
|
8
8
|
Cypress.Commands.add('handleHarvardKey', function (name) {
|
|
9
9
|
cy.log('🔓 Handling HarvardKey authentication via UI');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Clicking the button doesn't work for some reason, so we access the href attribute instead
|
|
21
|
-
return cy.navigateToHref('#idp_1001962798_button');
|
|
22
|
-
}).then(function (fullUrl) {
|
|
23
|
-
// Navigate to the Harvard login page using originWithKaixa
|
|
24
|
-
cy.origin('https://harvard.idp.cirrusidentity.com', {
|
|
25
|
-
args: { username: username, password: password, fullUrl: fullUrl },
|
|
26
|
-
}, function (args) {
|
|
10
|
+
// Get user credentials from environment variables
|
|
11
|
+
cy.env([name]).then(function (environment) {
|
|
12
|
+
var userInfo = environment[name];
|
|
13
|
+
if (!userInfo) {
|
|
14
|
+
throw new Error("Could not find ".concat(name, " in environment variables"));
|
|
15
|
+
}
|
|
16
|
+
// Destructure the user info object
|
|
17
|
+
var username = userInfo.username, password = userInfo.password;
|
|
18
|
+
// Get the Harvard login URL using originWithKaixa with auto-initialized functions
|
|
19
|
+
cy.origin('https://apps.cirrusidentity.com', function () {
|
|
27
20
|
Cypress.require('dceky');
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
// To go the login screen
|
|
22
|
+
// Clicking the button doesn't work for some reason, so we access the href attribute instead
|
|
23
|
+
return cy.navigateToHref('#idp_1001962798_button');
|
|
24
|
+
}).then(function (fullUrl) {
|
|
25
|
+
// Navigate to the Harvard login page using originWithKaixa
|
|
26
|
+
cy.origin('https://harvard.idp.cirrusidentity.com', {
|
|
27
|
+
args: { username: username, password: password, fullUrl: fullUrl },
|
|
28
|
+
}, function (args) {
|
|
29
|
+
Cypress.require('dceky');
|
|
30
|
+
var harvardUsername = args.username, harvardPassword = args.password, harvardLoginUrl = args.fullUrl;
|
|
31
|
+
cy.on('uncaught:exception', function (e) {
|
|
32
|
+
// Ignore known HarvardKey errors
|
|
33
|
+
if (!e.message.includes('ready is not defined')) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
// Visit the Harvard login page
|
|
39
|
+
cy.visit(harvardLoginUrl);
|
|
40
|
+
// Wait for and fill in the login form
|
|
41
|
+
cy.waitForElementVisible('#username');
|
|
42
|
+
cy.waitForElementVisible('#password');
|
|
43
|
+
cy.typeInto({ item: '#username', text: harvardUsername });
|
|
44
|
+
cy.typeInto({ item: '#password', text: harvardPassword });
|
|
45
|
+
// Submit the form
|
|
46
|
+
cy.get('input[type="submit"], button[type="submit"], .btn-primary').click();
|
|
35
47
|
});
|
|
36
|
-
// Visit the Harvard login page
|
|
37
|
-
cy.visit(harvardLoginUrl);
|
|
38
|
-
// Wait for and fill in the login form
|
|
39
|
-
cy.waitForElementVisible('#username');
|
|
40
|
-
cy.waitForElementVisible('#password');
|
|
41
|
-
cy.typeInto({ item: '#username', text: harvardUsername });
|
|
42
|
-
cy.typeInto({ item: '#password', text: harvardPassword });
|
|
43
|
-
// Submit the form
|
|
44
|
-
cy.get('input[type="submit"], button[type="submit"], .btn-primary').click();
|
|
45
48
|
});
|
|
46
49
|
});
|
|
47
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleHarvardKey.js","sourceRoot":"","sources":["../../../src/commands/handleHarvardKey.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAsBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,gBAAgB,GAAG;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,kBAAkB,EAClB,UACE,IAAY;QAEZ,EAAE,CAAC,GAAG,CAAC,8C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ChB,eAAe,GACtB,IAAI,QADkB,CACjB;oBAET,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,CAAQ;wBACnC,iCAAiC;wBACjC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;4BAChD,OAAO,IAAI,CAAC;wBACd,CAAC;wBACD,OAAO,KAAK,CAAC;oBACf,CAAC,CAAC,CAAC;oBAEH,+BAA+B;oBAC/B,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;oBAE1B,sCAAsC;oBACtC,EAAE,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;oBACtC,EAAE,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;oBAEtC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;oBAC1D,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;oBAE1D,kBAAkB;oBAClB,EAAE,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC,KAAK,EAAE,CAAC;gBAC9E,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,gBAAgB,CAAC"}
|
|
@@ -16,94 +16,96 @@ var launchAs = function () {
|
|
|
16
16
|
cy.visit(baseURL);
|
|
17
17
|
// Get courseId from environment variables if not provided
|
|
18
18
|
if (!courseId) {
|
|
19
|
-
var envCourseId = Cypress.
|
|
19
|
+
var envCourseId = Cypress.expose('courseId');
|
|
20
20
|
if (!envCourseId) {
|
|
21
21
|
throw new Error('Could not find courseId in environment variables');
|
|
22
22
|
}
|
|
23
23
|
courseId = Number.parseInt(envCourseId, 10);
|
|
24
24
|
}
|
|
25
25
|
// Get appName from environment variables if not provided
|
|
26
|
-
appName = appName || Cypress.
|
|
26
|
+
appName = appName || Cypress.expose('appName');
|
|
27
27
|
if (!appName) {
|
|
28
28
|
throw new Error('Could not find appName in environment variables');
|
|
29
29
|
}
|
|
30
30
|
// Get user accessToken from environment variables
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// List external tools in the course
|
|
40
|
-
return (cy
|
|
41
|
-
.request({
|
|
42
|
-
method: 'GET',
|
|
43
|
-
url: "https://canvas.harvard.edu/api/v1/courses/".concat(courseId, "/external_tools"),
|
|
44
|
-
body: {
|
|
45
|
-
per_page: 200,
|
|
46
|
-
access_token: accessToken,
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
.then(function (response) {
|
|
50
|
-
// Extract tools from the body
|
|
51
|
-
var externalTools = response.body;
|
|
52
|
-
// Find the external tool of interest
|
|
53
|
-
var matchingTool = externalTools.find(function (externalTool) {
|
|
54
|
-
// Skip non-nav items
|
|
55
|
-
if (
|
|
56
|
-
// No nav
|
|
57
|
-
!externalTool.course_navigation
|
|
58
|
-
// No nav information
|
|
59
|
-
|| typeof externalTool.course_navigation !== 'object') {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
// Skip non-labeled items
|
|
63
|
-
if (!externalTool.course_navigation.text) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
// Skip if the app name does not match the expected name
|
|
67
|
-
var thisAppName = (externalTool
|
|
68
|
-
.course_navigation
|
|
69
|
-
.text
|
|
70
|
-
.trim()
|
|
71
|
-
.toLowerCase());
|
|
72
|
-
return thisAppName === appName.trim().toLowerCase();
|
|
73
|
-
});
|
|
74
|
-
// Make sure we found the app
|
|
75
|
-
if (!matchingTool) {
|
|
76
|
-
throw new Error("Could not find any apps named \"".concat(appName, "\" in course ").concat(courseId));
|
|
31
|
+
cy.env([name]).then(function (environment) {
|
|
32
|
+
var userInfo = environment[name];
|
|
33
|
+
if (!userInfo) {
|
|
34
|
+
throw new Error("Could not find ".concat(name, " in environment variables"));
|
|
35
|
+
}
|
|
36
|
+
var accessToken = userInfo.accessToken;
|
|
37
|
+
if (!accessToken) {
|
|
38
|
+
throw new Error("Could not find accessToken for ".concat(name, " in environment variables"));
|
|
77
39
|
}
|
|
78
|
-
//
|
|
79
|
-
var toolId = (matchingTool === null || matchingTool === void 0 ? void 0 : matchingTool.id) || 0;
|
|
80
|
-
return cy.wrap(toolId);
|
|
81
|
-
})
|
|
82
|
-
.then(function (toolId) {
|
|
83
|
-
// Request sessionless launch URL
|
|
40
|
+
// List external tools in the course
|
|
84
41
|
return (cy
|
|
85
42
|
.request({
|
|
86
43
|
method: 'GET',
|
|
87
|
-
url: "https://canvas.harvard.edu/api/v1/courses/".concat(courseId, "/external_tools
|
|
44
|
+
url: "https://canvas.harvard.edu/api/v1/courses/".concat(courseId, "/external_tools"),
|
|
88
45
|
body: {
|
|
89
46
|
per_page: 200,
|
|
90
47
|
access_token: accessToken,
|
|
91
48
|
},
|
|
92
49
|
})
|
|
93
|
-
.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
50
|
+
.then(function (response) {
|
|
51
|
+
// Extract tools from the body
|
|
52
|
+
var externalTools = response.body;
|
|
53
|
+
// Find the external tool of interest
|
|
54
|
+
var matchingTool = externalTools.find(function (externalTool) {
|
|
55
|
+
// Skip non-nav items
|
|
56
|
+
if (
|
|
57
|
+
// No nav
|
|
58
|
+
!externalTool.course_navigation
|
|
59
|
+
// No nav information
|
|
60
|
+
|| typeof externalTool.course_navigation !== 'object') {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// Skip non-labeled items
|
|
64
|
+
if (!externalTool.course_navigation.text) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// Skip if the app name does not match the expected name
|
|
68
|
+
var thisAppName = (externalTool
|
|
69
|
+
.course_navigation
|
|
70
|
+
.text
|
|
71
|
+
.trim()
|
|
72
|
+
.toLowerCase());
|
|
73
|
+
return thisAppName === appName.trim().toLowerCase();
|
|
74
|
+
});
|
|
75
|
+
// Make sure we found the app
|
|
76
|
+
if (!matchingTool) {
|
|
77
|
+
throw new Error("Could not find any apps named \"".concat(appName, "\" in course ").concat(courseId));
|
|
100
78
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
79
|
+
// Get the toolId for the matching tool
|
|
80
|
+
var toolId = (matchingTool === null || matchingTool === void 0 ? void 0 : matchingTool.id) || 0;
|
|
81
|
+
return cy.wrap(toolId);
|
|
82
|
+
})
|
|
83
|
+
.then(function (toolId) {
|
|
84
|
+
// Request sessionless launch URL
|
|
85
|
+
return (cy
|
|
86
|
+
.request({
|
|
87
|
+
method: 'GET',
|
|
88
|
+
url: "https://canvas.harvard.edu/api/v1/courses/".concat(courseId, "/external_tools/sessionless_launch?id=").concat(toolId),
|
|
89
|
+
body: {
|
|
90
|
+
per_page: 200,
|
|
91
|
+
access_token: accessToken,
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
.its('body'));
|
|
95
|
+
})
|
|
96
|
+
.then(function (sessionlessLaunchInfo) {
|
|
97
|
+
cy.on('uncaught:exception', function (e) {
|
|
98
|
+
// Ignore known LTI launch errors
|
|
99
|
+
if (!e.message.includes('postMessage')) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
});
|
|
104
|
+
// Launch via the sessionless launch URL
|
|
105
|
+
var launchURL = sessionlessLaunchInfo.url;
|
|
106
|
+
cy.visit(launchURL);
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
107
109
|
});
|
|
108
110
|
};
|
|
109
111
|
/*----------------------------------------*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launchAs.js","sourceRoot":"","sources":["../../../src/commands/launchAs.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAkCjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,QAAQ,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,UAAU,EACV,UACE,IAAY,EACZ,IAGM;QAHN,qBAAA,EAAA,SAGM;QAEN,iBAAiB;QACjB,EAAE,CAAC,GAAG,CAAC,iCAAgB,IAAI,CAAE,CAAC,CAAC;QAE/B,mBAAmB;QACb,IAAA,QAAQ,GAAc,IAAI,SAAlB,EAAE,OAAO,GAAK,IAAI,QAAT,CAAU;QAEjC,2CAA2C;QAC3C,IAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1C,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAElB,0DAA0D;QAC1D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAM,WAAW,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"launchAs.js","sourceRoot":"","sources":["../../../src/commands/launchAs.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAkCjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,QAAQ,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,UAAU,EACV,UACE,IAAY,EACZ,IAGM;QAHN,qBAAA,EAAA,SAGM;QAEN,iBAAiB;QACjB,EAAE,CAAC,GAAG,CAAC,iCAAgB,IAAI,CAAE,CAAC,CAAC;QAE/B,mBAAmB;QACb,IAAA,QAAQ,GAAc,IAAI,SAAlB,EAAE,OAAO,GAAK,IAAI,QAAT,CAAU;QAEjC,2CAA2C;QAC3C,IAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1C,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAElB,0DAA0D;QAC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C,UAAC,qBAAqB;gBAC1B,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,CAAQ;oBACnC,iCAAiC;oBACjC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;wBACvC,OAAO,IAAI,CAAC;oBACd,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CAAC,CAAC;gBAEH,wCAAwC;gBACxC,IAAM,SAAS,GAAG,qBAAqB,CAAC,GAAG,CAAC;gBAC5C,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACtB,CAAC,CAAC,CACL,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,QAAQ,CAAC"}
|
|
@@ -52,65 +52,68 @@ var getFormData = function (html, formSelector) {
|
|
|
52
52
|
var logIntoPorta = function () {
|
|
53
53
|
Cypress.Commands.add('logIntoPorta', function (name) {
|
|
54
54
|
cy.log('🔓 Handling HarvardKey authentication via API');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// Request 1: GET Cirrus Identity discovery page
|
|
66
|
-
cy.request({
|
|
67
|
-
url: LOGIN_PAGE,
|
|
68
|
-
followRedirect: true,
|
|
69
|
-
failOnStatusCode: false,
|
|
70
|
-
headers: htmlHeaders,
|
|
71
|
-
}).then(function (discoveryRes) {
|
|
72
|
-
// Parse discovery page for HarvardKey IdP button href
|
|
73
|
-
var btnMatch = discoveryRes.body.match(new RegExp("href=[\"']([^\"']+)[\"'][^>]*id=[\"']".concat(HARVARDKEY_IDP_BUTTON_ID, "[\"']")));
|
|
74
|
-
if (!btnMatch) {
|
|
75
|
-
throw new Error('Could not find HarvardKey IdP button link on discovery page');
|
|
55
|
+
// Get user credentials from environment variables
|
|
56
|
+
cy.env([name]).then(function (environment) {
|
|
57
|
+
var userInfo = environment[name];
|
|
58
|
+
if (!userInfo) {
|
|
59
|
+
throw new Error("Could not find ".concat(name, " in environment variables"));
|
|
60
|
+
}
|
|
61
|
+
var username = userInfo.username, password = userInfo.password;
|
|
62
|
+
// Check if username and password are set
|
|
63
|
+
if (!username || !password) {
|
|
64
|
+
throw new Error("Credential \"".concat(name, "\" is missing username and/or password"));
|
|
76
65
|
}
|
|
77
|
-
var
|
|
78
|
-
// Request
|
|
66
|
+
var htmlHeaders = { accept: 'text/html' };
|
|
67
|
+
// Request 1: GET Cirrus Identity discovery page
|
|
79
68
|
cy.request({
|
|
80
|
-
url:
|
|
69
|
+
url: LOGIN_PAGE,
|
|
81
70
|
followRedirect: true,
|
|
82
71
|
failOnStatusCode: false,
|
|
83
72
|
headers: htmlHeaders,
|
|
84
|
-
}).then(function (
|
|
85
|
-
// Parse
|
|
86
|
-
var
|
|
87
|
-
if (!
|
|
88
|
-
throw new Error('Could not find
|
|
73
|
+
}).then(function (discoveryRes) {
|
|
74
|
+
// Parse discovery page for HarvardKey IdP button href
|
|
75
|
+
var btnMatch = discoveryRes.body.match(new RegExp("href=[\"']([^\"']+)[\"'][^>]*id=[\"']".concat(HARVARDKEY_IDP_BUTTON_ID, "[\"']")));
|
|
76
|
+
if (!btnMatch) {
|
|
77
|
+
throw new Error('Could not find HarvardKey IdP button link on discovery page');
|
|
89
78
|
}
|
|
90
|
-
|
|
79
|
+
var idpUrl = "".concat(IDP_BASE_URL).concat(btnMatch[1]);
|
|
80
|
+
// Request 2: GET HarvardKey IdP login page
|
|
91
81
|
cy.request({
|
|
92
|
-
|
|
93
|
-
url: loginFormUrl,
|
|
94
|
-
form: true,
|
|
82
|
+
url: idpUrl,
|
|
95
83
|
followRedirect: true,
|
|
96
84
|
failOnStatusCode: false,
|
|
97
85
|
headers: htmlHeaders,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
throw new Error('Could not find SAML form in login response');
|
|
86
|
+
}).then(function (loginPageRes) {
|
|
87
|
+
// Parse login form action and hidden fields
|
|
88
|
+
var _a = getFormData(loginPageRes.body), loginFormUrl = _a.action, loginHiddenFields = _a.fields;
|
|
89
|
+
if (!loginFormUrl) {
|
|
90
|
+
throw new Error('Could not find login form action on HarvardKey page');
|
|
104
91
|
}
|
|
105
|
-
// Request
|
|
106
|
-
|
|
92
|
+
// Request 3: POST credentials to HarvardKey login form
|
|
93
|
+
cy.request({
|
|
107
94
|
method: 'POST',
|
|
108
|
-
url:
|
|
95
|
+
url: loginFormUrl,
|
|
109
96
|
form: true,
|
|
110
97
|
followRedirect: true,
|
|
111
98
|
failOnStatusCode: false,
|
|
112
99
|
headers: htmlHeaders,
|
|
113
|
-
body:
|
|
100
|
+
body: __assign(__assign({}, loginHiddenFields), { username: username, password: password }),
|
|
101
|
+
}).then(function (authRes) {
|
|
102
|
+
// Parse SAML form from login response
|
|
103
|
+
var _a = getFormData(authRes.body, 'form[action*="saml2-acs"]'), samlFormUrl = _a.action, samlHiddenFields = _a.fields;
|
|
104
|
+
if (!samlFormUrl) {
|
|
105
|
+
throw new Error('Could not find SAML form in login response');
|
|
106
|
+
}
|
|
107
|
+
// Request 4: POST SAML assertion to ACS
|
|
108
|
+
return cy.request({
|
|
109
|
+
method: 'POST',
|
|
110
|
+
url: samlFormUrl,
|
|
111
|
+
form: true,
|
|
112
|
+
followRedirect: true,
|
|
113
|
+
failOnStatusCode: false,
|
|
114
|
+
headers: htmlHeaders,
|
|
115
|
+
body: samlHiddenFields,
|
|
116
|
+
});
|
|
114
117
|
});
|
|
115
118
|
});
|
|
116
119
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logIntoPorta.js","sourceRoot":"","sources":["../../../src/commands/logIntoPorta.ts"],"names":[],"mappings":";AAAA,iCAAiC;;;;;;;;;;;;;AA6BjC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C,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dceky",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "Cypress toolkit for Harvard DCE",
|
|
5
5
|
"main": "./lib/src/index.js",
|
|
6
6
|
"types": "./lib/src/index.d.ts",
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"cypress": "^
|
|
55
|
+
"cypress": "^15.11.0"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -32,52 +32,55 @@ const handleHarvardKey = () => {
|
|
|
32
32
|
) => {
|
|
33
33
|
cy.log('🔓 Handling HarvardKey authentication via UI');
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
// Get user credentials from environment variables
|
|
36
|
+
cy.env([name]).then((environment) => {
|
|
37
|
+
const userInfo = environment[name];
|
|
38
|
+
if (!userInfo) {
|
|
39
|
+
throw new Error(`Could not find ${name} in environment variables`);
|
|
40
|
+
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
// Destructure the user info object
|
|
43
|
+
const { username, password } = userInfo;
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Cypress.require('dceky');
|
|
46
|
-
// To go the login screen
|
|
47
|
-
// Clicking the button doesn't work for some reason, so we access the href attribute instead
|
|
48
|
-
return cy.navigateToHref('#idp_1001962798_button');
|
|
49
|
-
}).then((fullUrl: string) => {
|
|
50
|
-
// Navigate to the Harvard login page using originWithKaixa
|
|
51
|
-
cy.origin('https://harvard.idp.cirrusidentity.com', {
|
|
52
|
-
args: { username, password, fullUrl },
|
|
53
|
-
}, (args) => {
|
|
45
|
+
// Get the Harvard login URL using originWithKaixa with auto-initialized functions
|
|
46
|
+
cy.origin('https://apps.cirrusidentity.com', () => {
|
|
54
47
|
Cypress.require('dceky');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
// To go the login screen
|
|
49
|
+
// Clicking the button doesn't work for some reason, so we access the href attribute instead
|
|
50
|
+
return cy.navigateToHref('#idp_1001962798_button');
|
|
51
|
+
}).then((fullUrl: string) => {
|
|
52
|
+
// Navigate to the Harvard login page using originWithKaixa
|
|
53
|
+
cy.origin('https://harvard.idp.cirrusidentity.com', {
|
|
54
|
+
args: { username, password, fullUrl },
|
|
55
|
+
}, (args) => {
|
|
56
|
+
Cypress.require('dceky');
|
|
57
|
+
const {
|
|
58
|
+
username: harvardUsername,
|
|
59
|
+
password: harvardPassword,
|
|
60
|
+
fullUrl: harvardLoginUrl,
|
|
61
|
+
} = args;
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
cy.on('uncaught:exception', (e: Error) => {
|
|
64
|
+
// Ignore known HarvardKey errors
|
|
65
|
+
if (!e.message.includes('ready is not defined')) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
});
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
// Visit the Harvard login page
|
|
72
|
+
cy.visit(harvardLoginUrl);
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
// Wait for and fill in the login form
|
|
75
|
+
cy.waitForElementVisible('#username');
|
|
76
|
+
cy.waitForElementVisible('#password');
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
cy.typeInto({ item: '#username', text: harvardUsername });
|
|
79
|
+
cy.typeInto({ item: '#password', text: harvardPassword });
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
// Submit the form
|
|
82
|
+
cy.get('input[type="submit"], button[type="submit"], .btn-primary').click();
|
|
83
|
+
});
|
|
81
84
|
});
|
|
82
85
|
});
|
|
83
86
|
},
|