@jahia/cypress 8.2.0 → 8.3.0
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/CHANGELOG.md +14 -0
- package/README.md +1 -4
- package/dist/support/jahiaLog.d.ts +3 -0
- package/dist/support/jahiaLog.js +40 -0
- package/dist/support/jfaker.d.ts +0 -1
- package/dist/support/jfaker.js +2 -5
- package/dist/support/registerSupport.js +2 -0
- package/dist/utils/UsersHelper.d.ts +56 -1
- package/dist/utils/UsersHelper.js +73 -9
- package/fixtures/groovy/admin/addUserToGroup.groovy +4 -3
- package/fixtures/groovy/admin/createUser.groovy +5 -3
- package/fixtures/groovy/admin/deleteUser.groovy +3 -3
- package/fixtures/groovy/logger.groovy +6 -0
- package/package.json +17 -4
- package/src/support/jahiaLog.ts +45 -0
- package/src/support/jfaker.ts +2 -5
- package/src/support/registerSupport.ts +2 -0
- package/src/utils/UsersHelper.ts +72 -13
- package/dist/injections/bash-data.d.ts +0 -1
- package/dist/injections/bash-data.js +0 -57
- package/docs/browser-helper.md +0 -158
- package/docs/context-reporter.md +0 -104
- package/docs/extended-logger.md +0 -403
- package/docs/jfaker.md +0 -450
- package/docs/js-errors-logger.md +0 -210
- package/schema.graphql +0 -4569
- package/src/injections/bash-data.ts +0 -54
- package/tests/cypress/e2e/jfaker.spec.ts +0 -411
- package/tests/cypress/e2e/modSince.spec.ts +0 -334
- package/tests/cypress.config.ts +0 -23
- package/tests/package.json +0 -41
- package/tests/reporter-config.json +0 -13
- package/tests/yarn.lock +0 -8578
- package/tsconfig.json +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @jahia/cypress Changelog
|
|
2
2
|
|
|
3
|
+
## 8.3.0
|
|
4
|
+
|
|
5
|
+
### New Features
|
|
6
|
+
|
|
7
|
+
* Add specs and tests marks to jahia log (#234)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Update UserHelpers: unify interfaces and internal variables; add logging; extend createUser with site-level operation (#228)
|
|
12
|
+
|
|
13
|
+
## 8.2.1
|
|
14
|
+
|
|
15
|
+
* Temporary remove bash injections which can be treated by antivirus as a potentially unsafe. They will be reworked and brought back later on. (#224)
|
|
16
|
+
|
|
3
17
|
## 8.2.0
|
|
4
18
|
|
|
5
19
|
* Add `context.tag()` function for adding tags (user-defined labels) that can be attached to test suites and individual tests to provide metadata about test characteristics, scope, and purpose (#221)
|
package/README.md
CHANGED
|
@@ -171,7 +171,4 @@ This is an Open-Source codebase, you can find more details about Open-Source @ J
|
|
|
171
171
|
|
|
172
172
|
## How to release
|
|
173
173
|
|
|
174
|
-
Releases are now
|
|
175
|
-
|
|
176
|
-
- Merge the `chore: release` PR from `github-actions`.
|
|
177
|
-
- From Github release panel, draft a new release with a tag named `vX.Y.Z` (use the same version as the one set by Chachalog in the `chore: release` PR) and a title `vX.Y.Z`. The release will be published to NPM automatically.
|
|
174
|
+
Releases are now automated using [Chachalog](https://github.com/GauBen/chachalog). To create a new release, merge the `chore: release` PR from `github-actions`: the package is then published to NPM and tagged `@jahia/cypress@X.Y.Z` automatically.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jahiaLog = void 0;
|
|
4
|
+
// Groovy script to be used for logging test suite and test case start/end markers
|
|
5
|
+
var loggerScript = 'groovy/logger.groovy';
|
|
6
|
+
var delimeters = { spec: '='.repeat(20), test: '-'.repeat(20) };
|
|
7
|
+
/**
|
|
8
|
+
* Generates a marker for the beginning or end of a test suite.
|
|
9
|
+
* @param action - The action being performed (e.g., "Starting" or "Ending").
|
|
10
|
+
* @param name - The name of the test suite.
|
|
11
|
+
* @returns A formatted string representing the suite marker.
|
|
12
|
+
*/
|
|
13
|
+
var specMarker = function (action, name) { return "".concat(delimeters.spec, " ").concat(action, " ").concat(name, " ").concat(delimeters.spec); };
|
|
14
|
+
/**
|
|
15
|
+
* Generates a marker for the beginning or end of a test.
|
|
16
|
+
* @param action - The action being performed (e.g., "Starting" or "Ending").
|
|
17
|
+
* @param title - The title of the test.
|
|
18
|
+
* @returns A formatted string representing the test marker.
|
|
19
|
+
*/
|
|
20
|
+
var testMarker = function (action, title) { return "".concat(delimeters.test, " ").concat(action, " ").concat(title, " ").concat(delimeters.test); };
|
|
21
|
+
/**
|
|
22
|
+
* Enables logging markers for the start and end of test suites and individual tests.
|
|
23
|
+
* This function sets up hooks to log messages before and after each test and suite execution.
|
|
24
|
+
* It uses a Groovy script to log the messages, which can be useful for tracking test execution in Jahia logs.
|
|
25
|
+
*/
|
|
26
|
+
var enableSpecsMarker = function () {
|
|
27
|
+
before(function () {
|
|
28
|
+
cy.executeGroovy(loggerScript, { MESSAGE: specMarker('[BEGIN SPEC]', Cypress.spec.name) });
|
|
29
|
+
});
|
|
30
|
+
beforeEach(function () {
|
|
31
|
+
cy.executeGroovy(loggerScript, { MESSAGE: testMarker('[BEGIN TEST]', this.currentTest.title) });
|
|
32
|
+
});
|
|
33
|
+
afterEach(function () {
|
|
34
|
+
cy.executeGroovy(loggerScript, { MESSAGE: testMarker('[END TEST]', this.currentTest.title) });
|
|
35
|
+
});
|
|
36
|
+
after(function () {
|
|
37
|
+
cy.executeGroovy(loggerScript, { MESSAGE: specMarker('[END SPEC]', Cypress.spec.name) });
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.jahiaLog = { enableSpecsMarker: enableSpecsMarker };
|
package/dist/support/jfaker.d.ts
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
* Available injection methods:
|
|
23
23
|
* - `.xss()` - Generate XSS injection payloads
|
|
24
24
|
* - `.sql()` - Generate SQL injection payloads
|
|
25
|
-
* - `.bash()` - Generate Bash injection payloads
|
|
26
25
|
* - `.chars()` - Generate random special characters
|
|
27
26
|
* - `.htmlentities()` - Generate HTML entities
|
|
28
27
|
* - `.numbers()` - Generate random numbers entities and edge cases
|
package/dist/support/jfaker.js
CHANGED
|
@@ -28,14 +28,12 @@ var faker_1 = require("@faker-js/faker");
|
|
|
28
28
|
// Import injection data from corresponding files in injections-ts directory
|
|
29
29
|
var xss_data_1 = require("../injections/xss-data");
|
|
30
30
|
var sql_data_1 = require("../injections/sql-data");
|
|
31
|
-
var bash_data_1 = require("../injections/bash-data");
|
|
32
31
|
var chars_data_1 = require("../injections/chars-data");
|
|
33
32
|
var htmlentities_data_1 = require("../injections/htmlentities-data");
|
|
34
33
|
var numbers_data_1 = require("../injections/numbers-data");
|
|
35
34
|
var injectionData = {
|
|
36
35
|
xss: xss_data_1.xssData,
|
|
37
36
|
sql: sql_data_1.sqlData,
|
|
38
|
-
bash: bash_data_1.bashData,
|
|
39
37
|
chars: chars_data_1.charsData,
|
|
40
38
|
htmlentities: htmlentities_data_1.htmlentitiesData,
|
|
41
39
|
numbers: numbers_data_1.numbersData
|
|
@@ -48,7 +46,7 @@ var ENV_INJECTIONS_TYPE = 'JAHIA_CYPRESS_INJECTION_TYPE';
|
|
|
48
46
|
var injectionsDefaultLength = { min: 2, max: 5 };
|
|
49
47
|
/**
|
|
50
48
|
* Store FakeData type in Cypress env for persistence across specs
|
|
51
|
-
* @param {string} type FakeData type: 'faker' | 'xss' | 'sql' | '
|
|
49
|
+
* @param {string} type FakeData type: 'faker' | 'xss' | 'sql' | 'chars' | 'htmlentities' | 'numbers'
|
|
52
50
|
* @returns void
|
|
53
51
|
*/
|
|
54
52
|
function setDataType(type) {
|
|
@@ -63,7 +61,7 @@ function getDataType() {
|
|
|
63
61
|
}
|
|
64
62
|
/**
|
|
65
63
|
* Generate injection data based on the specified type and length
|
|
66
|
-
* @param {string} type Injection type to generate (xss, sql,
|
|
64
|
+
* @param {string} type Injection type to generate (xss, sql, chars, htmlentities, numbers)
|
|
67
65
|
* @param {number} length Length of the generated injection (optional)
|
|
68
66
|
* @returns {string} Generated injection string
|
|
69
67
|
*/
|
|
@@ -171,7 +169,6 @@ var DeepApi = /** @class */ (function () {
|
|
|
171
169
|
* Available injection methods:
|
|
172
170
|
* - `.xss()` - Generate XSS injection payloads
|
|
173
171
|
* - `.sql()` - Generate SQL injection payloads
|
|
174
|
-
* - `.bash()` - Generate Bash injection payloads
|
|
175
172
|
* - `.chars()` - Generate random special characters
|
|
176
173
|
* - `.htmlentities()` - Generate HTML entities
|
|
177
174
|
* - `.numbers()` - Generate random numbers entities and edge cases
|
|
@@ -22,6 +22,7 @@ var testStep_1 = require("./testStep");
|
|
|
22
22
|
var jfaker_1 = require("./jfaker");
|
|
23
23
|
var modSince_1 = require("./modSince");
|
|
24
24
|
var contextReporter_1 = require("./contextReporter");
|
|
25
|
+
var jahiaLog_1 = require("./jahiaLog");
|
|
25
26
|
var registerSupport = function () {
|
|
26
27
|
Cypress.Commands.add('apolloClient', apollo_1.apolloClient);
|
|
27
28
|
Cypress.Commands.add('apollo', { prevSubject: 'optional' }, apollo_1.apollo);
|
|
@@ -38,6 +39,7 @@ var registerSupport = function () {
|
|
|
38
39
|
Cypress.Commands.add('step', testStep_1.step);
|
|
39
40
|
// Register it.since()/describe.since()
|
|
40
41
|
modSince_1.modSince.enable();
|
|
42
|
+
jahiaLog_1.jahiaLog.enableSpecsMarker();
|
|
41
43
|
/**
|
|
42
44
|
* Override Cypress `type()` command to interpret special characters (e.g., {, }, etc.) either literally or as commands.
|
|
43
45
|
* The behavior is controlled by the `parseSpecialCharSequences` option, which can be set to `true`
|
|
@@ -1,11 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grants one or more roles to a principal on a target node.
|
|
3
|
+
* @param {string} pathOrId JCR node path or identifier where roles are granted.
|
|
4
|
+
* @param {Array<string>} roleNames Role names to grant.
|
|
5
|
+
* @param {string} principalName Principal name (user or group) receiving roles.
|
|
6
|
+
* @param {string} principalType Principal type expected by the mutation.
|
|
7
|
+
* @returns {Cypress.Chainable} Cypress chainable for the GraphQL mutation request.
|
|
8
|
+
*/
|
|
1
9
|
export declare const grantRoles: (pathOrId: string, roleNames: Array<string>, principalName: string, principalType: string) => Cypress.Chainable;
|
|
10
|
+
/**
|
|
11
|
+
* Revokes one or more roles from a principal on a target node.
|
|
12
|
+
* @param {string} pathOrId JCR node path or identifier where roles are revoked.
|
|
13
|
+
* @param {Array<string>} roleNames Role names to revoke.
|
|
14
|
+
* @param {string} principalName Principal name (user or group) losing roles.
|
|
15
|
+
* @param {string} principalType Principal type expected by the mutation.
|
|
16
|
+
* @returns {Cypress.Chainable} Cypress chainable for the GraphQL mutation request.
|
|
17
|
+
*/
|
|
2
18
|
export declare const revokeRoles: (pathOrId: string, roleNames: Array<string>, principalName: string, principalType: string) => Cypress.Chainable;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a Jahia user using the Groovy fixture.
|
|
21
|
+
* @param {string} userName Username of the user to create.
|
|
22
|
+
* @param {string} password Password for the new user. Defaults to "password" when empty.
|
|
23
|
+
* @param {{name: string, value: string}[]} properties Optional user properties to set on creation.
|
|
24
|
+
* @param {string} siteKey Optional site key for site-scoped user creation.
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
3
27
|
export declare const createUser: (userName: string, password: string, properties?: {
|
|
4
28
|
name: string;
|
|
5
29
|
value: string;
|
|
6
|
-
}[]) => void;
|
|
30
|
+
}[], siteKey?: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves the JCR path of a user.
|
|
33
|
+
* @param {string} username Username to look up.
|
|
34
|
+
* @param {string} siteKey Optional site key for site-scoped users.
|
|
35
|
+
* @returns {Cypress.Chainable} Cypress chainable containing the GraphQL query response.
|
|
36
|
+
*/
|
|
7
37
|
export declare const getUserPath: (username: string, siteKey?: string) => Cypress.Chainable;
|
|
38
|
+
/**
|
|
39
|
+
* Deletes a Jahia user using the Groovy fixture.
|
|
40
|
+
* @param {string} userName Username of the user to delete.
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*/
|
|
8
43
|
export declare const deleteUser: (userName: string) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a Jahia users group using the Groovy fixture.
|
|
46
|
+
* @param {string} groupName Group name to create.
|
|
47
|
+
* @param {boolean} hidden Whether the group should be hidden.
|
|
48
|
+
* @param {string} siteKey Optional site key for site-scoped group creation.
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
9
51
|
export declare const createGroup: (groupName: string, hidden?: boolean, siteKey?: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Deletes a Jahia users group using the Groovy fixture.
|
|
54
|
+
* @param {string} groupName Group name to delete.
|
|
55
|
+
* @param {string} siteKey Optional site key for site-scoped group deletion.
|
|
56
|
+
* @returns {void}
|
|
57
|
+
*/
|
|
10
58
|
export declare const deleteGroup: (groupName: string, siteKey?: string) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Adds an existing user to a group using the Groovy fixture.
|
|
61
|
+
* @param {string} userName Username to add to the group.
|
|
62
|
+
* @param {string} groupName Group receiving the user.
|
|
63
|
+
* @param {string} siteKey Optional site key for site-scoped group membership.
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
11
66
|
export declare const addUserToGroup: (userName: string, groupName: string, siteKey?: string) => void;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addUserToGroup = exports.deleteGroup = exports.createGroup = exports.deleteUser = exports.getUserPath = exports.createUser = exports.revokeRoles = exports.grantRoles = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Grants one or more roles to a principal on a target node.
|
|
6
|
+
* @param {string} pathOrId JCR node path or identifier where roles are granted.
|
|
7
|
+
* @param {Array<string>} roleNames Role names to grant.
|
|
8
|
+
* @param {string} principalName Principal name (user or group) receiving roles.
|
|
9
|
+
* @param {string} principalType Principal type expected by the mutation.
|
|
10
|
+
* @returns {Cypress.Chainable} Cypress chainable for the GraphQL mutation request.
|
|
11
|
+
*/
|
|
4
12
|
var grantRoles = function (pathOrId, roleNames, principalName, principalType) {
|
|
5
|
-
cy.log(
|
|
13
|
+
cy.log("Grant role(s) ".concat(roleNames, " with principal type ").concat(principalType, " to ").concat(principalName, " on node ").concat(pathOrId));
|
|
6
14
|
return cy.apollo({
|
|
7
15
|
variables: {
|
|
8
16
|
pathOrId: pathOrId,
|
|
@@ -14,8 +22,16 @@ var grantRoles = function (pathOrId, roleNames, principalName, principalType) {
|
|
|
14
22
|
});
|
|
15
23
|
};
|
|
16
24
|
exports.grantRoles = grantRoles;
|
|
25
|
+
/**
|
|
26
|
+
* Revokes one or more roles from a principal on a target node.
|
|
27
|
+
* @param {string} pathOrId JCR node path or identifier where roles are revoked.
|
|
28
|
+
* @param {Array<string>} roleNames Role names to revoke.
|
|
29
|
+
* @param {string} principalName Principal name (user or group) losing roles.
|
|
30
|
+
* @param {string} principalType Principal type expected by the mutation.
|
|
31
|
+
* @returns {Cypress.Chainable} Cypress chainable for the GraphQL mutation request.
|
|
32
|
+
*/
|
|
17
33
|
var revokeRoles = function (pathOrId, roleNames, principalName, principalType) {
|
|
18
|
-
cy.log(
|
|
34
|
+
cy.log("Revoke role(s) ".concat(roleNames, " with principal type ").concat(principalType, " to ").concat(principalName, " on node ").concat(pathOrId));
|
|
19
35
|
return cy.apollo({
|
|
20
36
|
variables: {
|
|
21
37
|
pathOrId: pathOrId,
|
|
@@ -27,20 +43,38 @@ var revokeRoles = function (pathOrId, roleNames, principalName, principalType) {
|
|
|
27
43
|
});
|
|
28
44
|
};
|
|
29
45
|
exports.revokeRoles = revokeRoles;
|
|
30
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Creates a Jahia user using the Groovy fixture.
|
|
48
|
+
* @param {string} userName Username of the user to create.
|
|
49
|
+
* @param {string} password Password for the new user. Defaults to "password" when empty.
|
|
50
|
+
* @param {{name: string, value: string}[]} properties Optional user properties to set on creation.
|
|
51
|
+
* @param {string} siteKey Optional site key for site-scoped user creation.
|
|
52
|
+
* @returns {void}
|
|
53
|
+
*/
|
|
54
|
+
var createUser = function (userName, password, properties, siteKey) {
|
|
31
55
|
if (properties === void 0) { properties = []; }
|
|
56
|
+
if (siteKey === void 0) { siteKey = ''; }
|
|
57
|
+
cy.log("Creating ".concat(siteKey === '' ? 'server-level ' : ('site-level:' + siteKey), " user with name ").concat(userName));
|
|
32
58
|
var userProperties = properties.map(function (property) {
|
|
33
59
|
return 'properties.setProperty("' + property.name + '", "' + property.value + '")';
|
|
34
60
|
});
|
|
35
61
|
cy.executeGroovy('groovy/admin/createUser.groovy', {
|
|
36
|
-
|
|
62
|
+
USERNAME: userName,
|
|
37
63
|
PASSWORD: password ? password : 'password',
|
|
38
|
-
USER_PROPERTIES: userProperties ? userProperties.join('\n') : ''
|
|
64
|
+
USER_PROPERTIES: userProperties ? userProperties.join('\n') : '',
|
|
65
|
+
SITEKEY: siteKey
|
|
39
66
|
});
|
|
40
67
|
};
|
|
41
68
|
exports.createUser = createUser;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves the JCR path of a user.
|
|
71
|
+
* @param {string} username Username to look up.
|
|
72
|
+
* @param {string} siteKey Optional site key for site-scoped users.
|
|
73
|
+
* @returns {Cypress.Chainable} Cypress chainable containing the GraphQL query response.
|
|
74
|
+
*/
|
|
42
75
|
var getUserPath = function (username, siteKey) {
|
|
43
76
|
if (siteKey === void 0) { siteKey = ''; }
|
|
77
|
+
cy.log("Getting user path for ".concat(username));
|
|
44
78
|
return cy.apollo({
|
|
45
79
|
variables: {
|
|
46
80
|
siteKey: siteKey,
|
|
@@ -50,14 +84,28 @@ var getUserPath = function (username, siteKey) {
|
|
|
50
84
|
});
|
|
51
85
|
};
|
|
52
86
|
exports.getUserPath = getUserPath;
|
|
87
|
+
/**
|
|
88
|
+
* Deletes a Jahia user using the Groovy fixture.
|
|
89
|
+
* @param {string} userName Username of the user to delete.
|
|
90
|
+
* @returns {void}
|
|
91
|
+
*/
|
|
53
92
|
var deleteUser = function (userName) {
|
|
93
|
+
cy.log("Deleting user ".concat(userName));
|
|
54
94
|
cy.executeGroovy('groovy/admin/deleteUser.groovy', {
|
|
55
|
-
|
|
95
|
+
USERNAME: userName
|
|
56
96
|
});
|
|
57
97
|
};
|
|
58
98
|
exports.deleteUser = deleteUser;
|
|
99
|
+
/**
|
|
100
|
+
* Creates a Jahia users group using the Groovy fixture.
|
|
101
|
+
* @param {string} groupName Group name to create.
|
|
102
|
+
* @param {boolean} hidden Whether the group should be hidden.
|
|
103
|
+
* @param {string} siteKey Optional site key for site-scoped group creation.
|
|
104
|
+
* @returns {void}
|
|
105
|
+
*/
|
|
59
106
|
var createGroup = function (groupName, hidden, siteKey) {
|
|
60
107
|
if (siteKey === void 0) { siteKey = ''; }
|
|
108
|
+
cy.log("Creating ".concat(siteKey === '' ? 'server-level' : ('site-level:' + siteKey), " group ").concat(groupName));
|
|
61
109
|
cy.executeGroovy('groovy/admin/userGroupHelper.groovy', {
|
|
62
110
|
OPERATION: 'create',
|
|
63
111
|
GROUPNAME: groupName,
|
|
@@ -66,8 +114,15 @@ var createGroup = function (groupName, hidden, siteKey) {
|
|
|
66
114
|
});
|
|
67
115
|
};
|
|
68
116
|
exports.createGroup = createGroup;
|
|
117
|
+
/**
|
|
118
|
+
* Deletes a Jahia users group using the Groovy fixture.
|
|
119
|
+
* @param {string} groupName Group name to delete.
|
|
120
|
+
* @param {string} siteKey Optional site key for site-scoped group deletion.
|
|
121
|
+
* @returns {void}
|
|
122
|
+
*/
|
|
69
123
|
var deleteGroup = function (groupName, siteKey) {
|
|
70
124
|
if (siteKey === void 0) { siteKey = ''; }
|
|
125
|
+
cy.log("Deleting ".concat(siteKey === '' ? 'server-level' : ('site-level:' + siteKey), " group ").concat(groupName));
|
|
71
126
|
cy.executeGroovy('groovy/admin/userGroupHelper.groovy', {
|
|
72
127
|
OPERATION: 'delete',
|
|
73
128
|
GROUPNAME: groupName,
|
|
@@ -75,11 +130,20 @@ var deleteGroup = function (groupName, siteKey) {
|
|
|
75
130
|
});
|
|
76
131
|
};
|
|
77
132
|
exports.deleteGroup = deleteGroup;
|
|
133
|
+
/**
|
|
134
|
+
* Adds an existing user to a group using the Groovy fixture.
|
|
135
|
+
* @param {string} userName Username to add to the group.
|
|
136
|
+
* @param {string} groupName Group receiving the user.
|
|
137
|
+
* @param {string} siteKey Optional site key for site-scoped group membership.
|
|
138
|
+
* @returns {void}
|
|
139
|
+
*/
|
|
78
140
|
var addUserToGroup = function (userName, groupName, siteKey) {
|
|
141
|
+
if (siteKey === void 0) { siteKey = ''; }
|
|
142
|
+
cy.log("Add user ".concat(userName, " to ").concat(siteKey === '' ? 'server-level' : ('site-level:' + siteKey), " group ").concat(groupName));
|
|
79
143
|
cy.executeGroovy('groovy/admin/addUserToGroup.groovy', {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
144
|
+
USERNAME: userName,
|
|
145
|
+
GROUPNAME: groupName,
|
|
146
|
+
SITEKEY: siteKey
|
|
83
147
|
});
|
|
84
148
|
};
|
|
85
149
|
exports.addUserToGroup = addUserToGroup;
|
|
@@ -4,12 +4,13 @@ import org.jahia.services.usermanager.JahiaUserManagerService
|
|
|
4
4
|
import org.jahia.services.content.decorator.JCRGroupNode
|
|
5
5
|
import org.jahia.services.content.decorator.JCRUserNode
|
|
6
6
|
|
|
7
|
-
log.info("Add user
|
|
7
|
+
log.info("Add user USERNAME to group GROUPNAME")
|
|
8
|
+
String siteKey = "SITEKEY".equals("") ? null : "SITEKEY";
|
|
8
9
|
JCRTemplate.getInstance().doExecuteWithSystemSession(session -> {
|
|
9
10
|
JahiaUserManagerService userManagerService = JahiaUserManagerService.getInstance()
|
|
10
11
|
JahiaGroupManagerService groupManagerService = JahiaGroupManagerService.getInstance()
|
|
11
|
-
JCRGroupNode groupNode = groupManagerService.lookupGroup(
|
|
12
|
-
JCRUserNode userNode = userManagerService.lookupUser("
|
|
12
|
+
JCRGroupNode groupNode = groupManagerService.lookupGroup(siteKey, "GROUPNAME", session)
|
|
13
|
+
JCRUserNode userNode = userManagerService.lookupUser("USERNAME")
|
|
13
14
|
if (!groupNode.isMember(userNode)) {
|
|
14
15
|
groupNode.addMember(userNode)
|
|
15
16
|
}
|
|
@@ -7,14 +7,16 @@ import javax.jcr.RepositoryException
|
|
|
7
7
|
JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback() {
|
|
8
8
|
@Override
|
|
9
9
|
Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
|
|
10
|
-
log.info("Create user :
|
|
10
|
+
log.info("Create user : USERNAME")
|
|
11
|
+
|
|
12
|
+
String siteKey = "SITEKEY".equals("") ? null : "SITEKEY";
|
|
11
13
|
JahiaUserManagerService userManagerService = JahiaUserManagerService.getInstance()
|
|
12
14
|
|
|
13
15
|
Properties properties = new Properties()
|
|
14
16
|
USER_PROPERTIES
|
|
15
17
|
|
|
16
|
-
userManagerService.createUser("
|
|
18
|
+
userManagerService.createUser("USERNAME", siteKey, "PASSWORD", properties, session)
|
|
17
19
|
session.save()
|
|
18
20
|
return null
|
|
19
21
|
}
|
|
20
|
-
})
|
|
22
|
+
})
|
|
@@ -7,15 +7,15 @@ import javax.jcr.RepositoryException
|
|
|
7
7
|
JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback() {
|
|
8
8
|
@Override
|
|
9
9
|
Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
|
|
10
|
-
log.info("Delete user :
|
|
10
|
+
log.info("Delete user : USERNAME" );
|
|
11
11
|
|
|
12
12
|
JahiaUserManagerService userManagerService = JahiaUserManagerService.getInstance();
|
|
13
|
-
def user = userManagerService.getUserPath("
|
|
13
|
+
def user = userManagerService.getUserPath("USERNAME");
|
|
14
14
|
if (user) {
|
|
15
15
|
userManagerService.deleteUser(user, session);
|
|
16
16
|
session.save();
|
|
17
17
|
} else {
|
|
18
|
-
log.warn("User
|
|
18
|
+
log.warn("User USERNAME cannot be deleted. User not found");
|
|
19
19
|
}
|
|
20
20
|
return null;
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jahia/cypress",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "tsc",
|
|
6
6
|
"lint": "eslint src -c .eslintrc.json --ext .ts --max-warnings=0"
|
|
@@ -13,13 +13,26 @@
|
|
|
13
13
|
},
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"src",
|
|
19
|
+
"fixtures",
|
|
20
|
+
"ci.build.sh",
|
|
21
|
+
"ci.startup.sh",
|
|
22
|
+
"env.debug.sh",
|
|
23
|
+
"env.provision.sh",
|
|
24
|
+
"env.run.sh",
|
|
25
|
+
"set-env.sh",
|
|
26
|
+
"env.Dockerfile",
|
|
27
|
+
"env.Dockerfile.dockerignore"
|
|
28
|
+
],
|
|
16
29
|
"license": "MIT",
|
|
17
30
|
"repository": {
|
|
18
31
|
"type": "git",
|
|
19
32
|
"url": "git+https://github.com/Jahia/jahia-cypress.git"
|
|
20
33
|
},
|
|
21
34
|
"devDependencies": {
|
|
22
|
-
"@chachalog/types": "^0.5.
|
|
35
|
+
"@chachalog/types": "^0.5.2",
|
|
23
36
|
"@jahia/eslint-config": "^2.2.0",
|
|
24
37
|
"@typescript-eslint/eslint-plugin": "^8.57.1",
|
|
25
38
|
"@typescript-eslint/parser": "^8.57.1",
|
|
@@ -32,6 +45,7 @@
|
|
|
32
45
|
"eslint-plugin-react": "^7.32.2",
|
|
33
46
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
34
47
|
"mochawesome": "^6.3.1",
|
|
48
|
+
"pkg-pr-new": "^0.0.86",
|
|
35
49
|
"typescript": "^5.9.3"
|
|
36
50
|
},
|
|
37
51
|
"dependencies": {
|
|
@@ -41,6 +55,5 @@
|
|
|
41
55
|
"cypress-real-events": "^1.11.0",
|
|
42
56
|
"graphql": "^15.5.0",
|
|
43
57
|
"graphql-tag": "^2.11.0"
|
|
44
|
-
}
|
|
45
|
-
"packageManager": "yarn@4.12.0"
|
|
58
|
+
}
|
|
46
59
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
// Groovy script to be used for logging test suite and test case start/end markers
|
|
3
|
+
const loggerScript = 'groovy/logger.groovy';
|
|
4
|
+
const delimeters = {spec: '='.repeat(20), test: '-'.repeat(20)};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a marker for the beginning or end of a test suite.
|
|
8
|
+
* @param action - The action being performed (e.g., "Starting" or "Ending").
|
|
9
|
+
* @param name - The name of the test suite.
|
|
10
|
+
* @returns A formatted string representing the suite marker.
|
|
11
|
+
*/
|
|
12
|
+
const specMarker = (action: string, name: string): string => `${delimeters.spec} ${action} ${name} ${delimeters.spec}`;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generates a marker for the beginning or end of a test.
|
|
16
|
+
* @param action - The action being performed (e.g., "Starting" or "Ending").
|
|
17
|
+
* @param title - The title of the test.
|
|
18
|
+
* @returns A formatted string representing the test marker.
|
|
19
|
+
*/
|
|
20
|
+
const testMarker = (action: string, title: string): string => `${delimeters.test} ${action} ${title} ${delimeters.test}`;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Enables logging markers for the start and end of test suites and individual tests.
|
|
24
|
+
* This function sets up hooks to log messages before and after each test and suite execution.
|
|
25
|
+
* It uses a Groovy script to log the messages, which can be useful for tracking test execution in Jahia logs.
|
|
26
|
+
*/
|
|
27
|
+
const enableSpecsMarker = (): void => {
|
|
28
|
+
before(() => {
|
|
29
|
+
cy.executeGroovy(loggerScript, {MESSAGE: specMarker('[BEGIN SPEC]', Cypress.spec.name)});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
beforeEach(function () {
|
|
33
|
+
cy.executeGroovy(loggerScript, {MESSAGE: testMarker('[BEGIN TEST]', this.currentTest!.title)});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterEach(function () {
|
|
37
|
+
cy.executeGroovy(loggerScript, {MESSAGE: testMarker('[END TEST]', this.currentTest!.title)});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
after(() => {
|
|
41
|
+
cy.executeGroovy(loggerScript, {MESSAGE: specMarker('[END SPEC]', Cypress.spec.name)});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const jahiaLog = {enableSpecsMarker};
|
package/src/support/jfaker.ts
CHANGED
|
@@ -18,7 +18,6 @@ import {faker} from '@faker-js/faker';
|
|
|
18
18
|
// Import injection data from corresponding files in injections-ts directory
|
|
19
19
|
import {xssData} from '../injections/xss-data';
|
|
20
20
|
import {sqlData} from '../injections/sql-data';
|
|
21
|
-
import {bashData} from '../injections/bash-data';
|
|
22
21
|
import {charsData} from '../injections/chars-data';
|
|
23
22
|
import {htmlentitiesData} from '../injections/htmlentities-data';
|
|
24
23
|
import {numbersData} from '../injections/numbers-data';
|
|
@@ -26,7 +25,6 @@ import {numbersData} from '../injections/numbers-data';
|
|
|
26
25
|
const injectionData: Record<string, string[]> = {
|
|
27
26
|
xss: xssData,
|
|
28
27
|
sql: sqlData,
|
|
29
|
-
bash: bashData,
|
|
30
28
|
chars: charsData,
|
|
31
29
|
htmlentities: htmlentitiesData,
|
|
32
30
|
numbers: numbersData
|
|
@@ -42,7 +40,7 @@ const injectionsDefaultLength = {min: 2, max: 5};
|
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
42
|
* Store FakeData type in Cypress env for persistence across specs
|
|
45
|
-
* @param {string} type FakeData type: 'faker' | 'xss' | 'sql' | '
|
|
43
|
+
* @param {string} type FakeData type: 'faker' | 'xss' | 'sql' | 'chars' | 'htmlentities' | 'numbers'
|
|
46
44
|
* @returns void
|
|
47
45
|
*/
|
|
48
46
|
function setDataType(type: string): void {
|
|
@@ -59,7 +57,7 @@ function getDataType(): string | undefined {
|
|
|
59
57
|
|
|
60
58
|
/**
|
|
61
59
|
* Generate injection data based on the specified type and length
|
|
62
|
-
* @param {string} type Injection type to generate (xss, sql,
|
|
60
|
+
* @param {string} type Injection type to generate (xss, sql, chars, htmlentities, numbers)
|
|
63
61
|
* @param {number} length Length of the generated injection (optional)
|
|
64
62
|
* @returns {string} Generated injection string
|
|
65
63
|
*/
|
|
@@ -175,7 +173,6 @@ class DeepApi {
|
|
|
175
173
|
* Available injection methods:
|
|
176
174
|
* - `.xss()` - Generate XSS injection payloads
|
|
177
175
|
* - `.sql()` - Generate SQL injection payloads
|
|
178
|
-
* - `.bash()` - Generate Bash injection payloads
|
|
179
176
|
* - `.chars()` - Generate random special characters
|
|
180
177
|
* - `.htmlentities()` - Generate HTML entities
|
|
181
178
|
* - `.numbers()` - Generate random numbers entities and edge cases
|
|
@@ -8,6 +8,7 @@ import {step} from './testStep';
|
|
|
8
8
|
import {jfaker} from './jfaker';
|
|
9
9
|
import {modSince} from './modSince';
|
|
10
10
|
import {collect as contextCollector} from './contextReporter';
|
|
11
|
+
import {jahiaLog} from './jahiaLog';
|
|
11
12
|
|
|
12
13
|
export const registerSupport = (): void => {
|
|
13
14
|
Cypress.Commands.add('apolloClient', apolloClient);
|
|
@@ -30,6 +31,7 @@ export const registerSupport = (): void => {
|
|
|
30
31
|
|
|
31
32
|
// Register it.since()/describe.since()
|
|
32
33
|
modSince.enable();
|
|
34
|
+
jahiaLog.enableSpecsMarker();
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* Override Cypress `type()` command to interpret special characters (e.g., {, }, etc.) either literally or as commands.
|