You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Some tests use different DBs, so using "*" for now
45
+
constdbName="*";
46
+
// GRANTS READ/WRITE SERVICE ACCOUNT
47
+
constreadWriteGrants=[
48
+
`GRANT ACCESS ON DATABASE * TO ${INT_TEST_ROLE_NAME}`,
49
+
`GRANT SHOW CONSTRAINT ON DATABASE ${dbName} TO ${INT_TEST_ROLE_NAME}`,
50
+
`GRANT SHOW INDEX ON DATABASE ${dbName} TO ${INT_TEST_ROLE_NAME}`,
51
+
`GRANT MATCH {*} ON GRAPH ${dbName} TO ${INT_TEST_ROLE_NAME}`,
52
+
`GRANT EXECUTE PROCEDURE * ON DBMS TO ${INT_TEST_ROLE_NAME}`,
53
+
`GRANT EXECUTE FUNCTION * ON DBMS TO ${INT_TEST_ROLE_NAME}`,
54
+
`GRANT WRITE ON GRAPH ${dbName} TO ${INT_TEST_ROLE_NAME}`,
55
+
`GRANT NAME MANAGEMENT ON DATABASE ${dbName} TO ${INT_TEST_ROLE_NAME}`,
56
+
];
57
+
58
+
try{
59
+
session=driver.session();
60
+
awaitsession.run(cypherCreateUser);
61
+
awaitsession.run(cypherCreateRole);
62
+
awaitsession.run(cypherGrantRole);
63
+
64
+
for(constcypherGrantofreadWriteGrants){
65
+
awaitsession.run(cypherGrant);
66
+
}
67
+
}catch(error){
68
+
if(errorHasGQLStatus("42NFF")){
69
+
console.log(
70
+
`\nJest /packages/graphql setup: Will NOT create a separate integration test user and role as the command is not supported in the current environment.`
71
+
);
72
+
}else{
73
+
throwerror;
74
+
}
75
+
}finally{
76
+
if(session){
77
+
awaitsession.close();
78
+
}
79
+
}
80
+
}
81
+
82
+
asyncfunctiondropTestUserAndRole(driver){
83
+
letsession=null;
84
+
85
+
try{
86
+
session=driver.session();
87
+
awaitsession.run(cypherDropUser);
88
+
awaitsession.run(cypherDropRole);
89
+
}catch(error){
90
+
if(errorHasGQLStatus("50N42")){
91
+
console.log(
92
+
`\nJest /packages/graphql setup: Failure to drop test user/role, this is expected if the user/role does not exist. Error: ${error.message}`
93
+
);
94
+
}else{
95
+
throwerror;
96
+
}
97
+
}finally{
98
+
if(session){
99
+
awaitsession.close();
100
+
}
101
+
}
102
+
}
103
+
104
+
asyncfunctionsetupTestDatabase(driver,neoURL){
30
105
constcypherCreateDb=`CREATE OR REPLACE DATABASE ${INT_TEST_DB_NAME} WAIT`;
31
106
letsession=null;
32
107
@@ -54,7 +129,7 @@ module.exports = async function globalSetup() {
54
129
);
55
130
}else{
56
131
console.log(
57
-
`\nJest /packages/graphql setup: Failure to create test DB on neo4j @ ${NEO_URL}, cypher: "${cypherCreateDb}", Error: ${error.message}. Falling back to drop data.`
132
+
`\nJest /packages/graphql setup: Failure to create test DB on neo4j @ ${neoURL}, cypher: "${cypherCreateDb}", Error: ${error.message}. Falling back to drop data.`
58
133
);
59
134
awaitdropDataAndIndexes(session);
60
135
}
@@ -63,81 +138,14 @@ module.exports = async function globalSetup() {
63
138
awaitsession.close();
64
139
}
65
140
}
66
-
if(process.env.USE_RESTRICTED_USER==="true"){
67
-
// Some tests use different DBs, so using "*" for now
68
-
constdbName="*";
69
-
// GRANTS READ/WRITE SERVICE ACCOUNT
70
-
constreadWriteGrants=[
71
-
`GRANT ACCESS ON DATABASE * TO ${INT_TEST_ROLE_NAME}`,
72
-
`GRANT SHOW CONSTRAINT ON DATABASE ${dbName} TO ${INT_TEST_ROLE_NAME}`,
73
-
`GRANT SHOW INDEX ON DATABASE ${dbName} TO ${INT_TEST_ROLE_NAME}`,
74
-
`GRANT MATCH {*} ON GRAPH ${dbName} TO ${INT_TEST_ROLE_NAME}`,
75
-
`GRANT EXECUTE PROCEDURE * ON DBMS TO ${INT_TEST_ROLE_NAME}`,
76
-
`GRANT EXECUTE FUNCTION * ON DBMS TO ${INT_TEST_ROLE_NAME}`,
77
-
`GRANT WRITE ON GRAPH ${dbName} TO ${INT_TEST_ROLE_NAME}`,
78
-
`GRANT NAME MANAGEMENT ON DATABASE ${dbName} TO ${INT_TEST_ROLE_NAME}`,
79
-
];
80
-
81
-
try{
82
-
session=driver.session();
83
-
awaitdropUserAndRole(session);
84
-
}catch(error){
85
-
if(errorHasGQLStatus("50N42")){
86
-
console.log(
87
-
`\nJest /packages/graphql setup: Failure to drop test user/role, this is expected if the user/role does not exist. Error: ${error.message}`
88
-
);
89
-
}else{
90
-
throwerror;
91
-
}
92
-
}finally{
93
-
if(session){
94
-
awaitsession.close();
95
-
}
96
-
}
97
-
98
-
try{
99
-
session=driver.session();
100
-
awaitcreateUserAndRole(session);
101
-
102
-
for(constcypherGrantofreadWriteGrants){
103
-
awaitsession.run(cypherGrant);
104
-
}
105
-
}catch(error){
106
-
if(errorHasGQLStatus("42NFF")){
107
-
console.log(
108
-
`\nJest /packages/graphql setup: Will NOT create a separate integration test user and role as the command is not supported in the current environment.`
109
-
);
110
-
}else{
111
-
throwerror;
112
-
}
113
-
}finally{
114
-
if(session){
115
-
awaitsession.close();
116
-
}
117
-
}
118
-
}
119
-
if(driver){
120
-
awaitdriver.close();
121
-
}
122
-
};
141
+
}
123
142
124
143
asyncfunctiondropDataAndIndexes(session){
125
144
awaitsession.run(cypherDropData);
126
145
awaitsession.run(cypherDropIndexes);
127
146
}
128
147
129
-
asyncfunctiondropUserAndRole(session){
130
-
awaitsession.run(cypherDropUser);
131
-
awaitsession.run(cypherDropRole);
132
-
}
133
-
134
-
asyncfunctioncreateUserAndRole(session){
135
-
awaitsession.run(cypherCreateUser);
136
-
awaitsession.run(cypherCreateRole);
137
-
awaitsession.run(cypherGrantRole);
138
-
}
139
-
140
-
/* Dummy Javascript copy of the utility function available at: ./src/utils/error-has-gql-status */
148
+
/* Javascript copy of the utility function available at: ./src/utils/error-has-gql-status */
0 commit comments