@jahia/cypress 3.15.0 → 3.17.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.
@@ -7,6 +7,7 @@ export declare const addNode: (variables: {
7
7
  name: string;
8
8
  properties?: any[];
9
9
  children?: any[];
10
+ mixins?: any[];
10
11
  }) => Cypress.Chainable;
11
12
  export declare const getNodeByPath: (path: string, properties?: string[], language?: string, childrenTypes?: string[], workspace?: 'EDIT' | 'LIVE') => Cypress.Chainable;
12
13
  export declare const getNodeAcl: (path: string) => Cypress.Chainable;
@@ -1,6 +1,8 @@
1
1
  export declare const grantRoles: (pathOrId: string, roleNames: Array<string>, principalName: string, principalType: string) => Cypress.Chainable;
2
+ export declare const revokeRoles: (pathOrId: string, roleNames: Array<string>, principalName: string, principalType: string) => Cypress.Chainable;
2
3
  export declare const createUser: (userName: string, password: string, properties?: {
3
4
  name: string;
4
5
  value: string;
5
6
  }[]) => void;
6
7
  export declare const deleteUser: (userName: string) => void;
8
+ export declare const addUserToGroup: (userName: string, groupName: string, siteKey?: string) => void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.deleteUser = exports.createUser = exports.grantRoles = void 0;
3
+ exports.addUserToGroup = exports.deleteUser = exports.createUser = exports.revokeRoles = exports.grantRoles = void 0;
4
4
  var grantRoles = function (pathOrId, roleNames, principalName, principalType) {
5
5
  cy.log('Grant role(s) ' + roleNames + ' with principal type ' + principalType + ' to ' + principalName + ' on node ' + pathOrId);
6
6
  return cy.apollo({
@@ -14,6 +14,19 @@ var grantRoles = function (pathOrId, roleNames, principalName, principalType) {
14
14
  });
15
15
  };
16
16
  exports.grantRoles = grantRoles;
17
+ var revokeRoles = function (pathOrId, roleNames, principalName, principalType) {
18
+ cy.log('Revoke role(s) ' + roleNames + ' with principal type ' + principalType + ' to ' + principalName + ' on node ' + pathOrId);
19
+ return cy.apollo({
20
+ variables: {
21
+ pathOrId: pathOrId,
22
+ roleNames: roleNames,
23
+ principalName: principalName,
24
+ principalType: principalType
25
+ },
26
+ mutationFile: 'graphql/jcr/mutation/revokeRoles.graphql'
27
+ });
28
+ };
29
+ exports.revokeRoles = revokeRoles;
17
30
  var createUser = function (userName, password, properties) {
18
31
  if (properties === void 0) { properties = []; }
19
32
  var userProperties = properties.map(function (property) {
@@ -32,3 +45,11 @@ var deleteUser = function (userName) {
32
45
  });
33
46
  };
34
47
  exports.deleteUser = deleteUser;
48
+ var addUserToGroup = function (userName, groupName, siteKey) {
49
+ cy.executeGroovy('groovy/admin/addUserToGroup.groovy', {
50
+ USER_NAME: userName,
51
+ GROUP_NAME: groupName,
52
+ SITE_KEY: siteKey ? "\"" + siteKey + "\"" : 'null'
53
+ });
54
+ };
55
+ exports.addUserToGroup = addUserToGroup;
@@ -1,10 +1,11 @@
1
- mutation addNode($parentPathOrId: String!, $name: String!, $primaryNodeType: String!, $children: [InputJCRNode] = [], $properties: [InputJCRProperty]) {
1
+ mutation addNode($parentPathOrId: String!, $name: String!, $primaryNodeType: String!, $children: [InputJCRNode] = [], $properties: [InputJCRProperty], $mixins: [String] = []) {
2
2
  jcr(workspace: EDIT) {
3
3
  addNode(
4
4
  parentPathOrId: $parentPathOrId,
5
5
  name: $name,
6
6
  primaryNodeType: $primaryNodeType,
7
7
  properties: $properties,
8
+ mixins: $mixins
8
9
  ) {
9
10
  addChildrenBatch(nodes: $children){
10
11
  uuid
@@ -0,0 +1,16 @@
1
+ mutation revokeRoles(
2
+ $pathOrId: String!
3
+ $roleNames: [String]!
4
+ $principalName: String!
5
+ $principalType: PrincipalType!
6
+ ) {
7
+ jcr {
8
+ mutateNode(pathOrId: $pathOrId) {
9
+ revokeRoles(
10
+ roleNames: $roleNames
11
+ principalType: $principalType
12
+ principalName: $principalName
13
+ )
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,17 @@
1
+ import org.jahia.services.content.JCRTemplate
2
+ import org.jahia.services.usermanager.JahiaGroupManagerService
3
+ import org.jahia.services.usermanager.JahiaUserManagerService
4
+ import org.jahia.services.content.decorator.JCRGroupNode
5
+ import org.jahia.services.content.decorator.JCRUserNode
6
+
7
+ log.info("Add user USER_NAME to group GROUP_NAME")
8
+ JCRTemplate.getInstance().doExecuteWithSystemSession(session -> {
9
+ JahiaUserManagerService userManagerService = JahiaUserManagerService.getInstance()
10
+ JahiaGroupManagerService groupManagerService = JahiaGroupManagerService.getInstance()
11
+ JCRGroupNode groupNode = groupManagerService.lookupGroup(SITE_KEY, "GROUP_NAME", session)
12
+ JCRUserNode userNode = userManagerService.lookupUser("USER_NAME")
13
+ if (!groupNode.isMember(userNode)) {
14
+ groupNode.addMember(userNode)
15
+ }
16
+ session.save()
17
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.15.0",
3
+ "version": "3.17.0",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -36,7 +36,7 @@ export const deleteNodeProperty = (pathOrId: string, property: string, language:
36
36
  };
37
37
 
38
38
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- export const addNode = (variables: { parentPathOrId: string, primaryNodeType: string, name: string, properties?: any[], children?: any[] }): Cypress.Chainable => {
39
+ export const addNode = (variables: { parentPathOrId: string, primaryNodeType: string, name: string, properties?: any[], children?: any[], mixins?: any[] }): Cypress.Chainable => {
40
40
  return cy.apollo({
41
41
  variables: variables,
42
42
  mutationFile: 'graphql/jcr/mutation/addNode.graphql'
@@ -12,6 +12,19 @@ export const grantRoles = (pathOrId: string, roleNames: Array<string>, principal
12
12
  });
13
13
  };
14
14
 
15
+ export const revokeRoles = (pathOrId: string, roleNames: Array<string>, principalName: string, principalType: string): Cypress.Chainable => {
16
+ cy.log('Revoke role(s) ' + roleNames + ' with principal type ' + principalType + ' to ' + principalName + ' on node ' + pathOrId);
17
+ return cy.apollo({
18
+ variables: {
19
+ pathOrId: pathOrId,
20
+ roleNames: roleNames,
21
+ principalName: principalName,
22
+ principalType: principalType
23
+ },
24
+ mutationFile: 'graphql/jcr/mutation/revokeRoles.graphql'
25
+ });
26
+ };
27
+
15
28
  export const createUser = (userName: string, password: string, properties: { name: string, value: string }[] = []): void => {
16
29
  const userProperties = properties.map(property => {
17
30
  return 'properties.setProperty("' + property.name + '", "' + property.value + '")';
@@ -28,3 +41,11 @@ export const deleteUser = (userName: string): void => {
28
41
  USER_NAME: userName
29
42
  });
30
43
  };
44
+
45
+ export const addUserToGroup = (userName: string, groupName: string, siteKey?: string): void => {
46
+ cy.executeGroovy('groovy/admin/addUserToGroup.groovy', {
47
+ USER_NAME: userName,
48
+ GROUP_NAME: groupName,
49
+ SITE_KEY: siteKey ? `"${siteKey}"` : 'null'
50
+ });
51
+ };