This is an automated email from the ASF dual-hosted git repository. ocket8888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 6bcca11 Fix roles hard code for TP integration test (#6139)
6bcca11 is described below
commit 6bcca115a4ec3e10a2bbee5313981d5445f70647
Author: dpham <[email protected]>
AuthorDate: Thu Aug 26 16:16:28 2021 -0600
Fix roles hard code for TP integration test (#6139)
* Fix roles hard code
* Update randomize in API files
* Fix typo ?
* Fix reviewed
* Fix template string
* Fix template string compare
Co-authored-by: Pham, Dandy (Contractor) <[email protected]>
---
traffic_portal/test/integration/CommonUtils/API.ts | 8 +-
.../test/integration/Data/prerequisites.ts | 96 +++++++++++++++++++---
2 files changed, 90 insertions(+), 14 deletions(-)
diff --git a/traffic_portal/test/integration/CommonUtils/API.ts
b/traffic_portal/test/integration/CommonUtils/API.ts
index 2a626a3..8e1a8eb 100644
--- a/traffic_portal/test/integration/CommonUtils/API.ts
+++ b/traffic_portal/test/integration/CommonUtils/API.ts
@@ -259,9 +259,13 @@ export class API {
return null;
}
for (const request of data.getRequest) {
- const query =
`?${encodeURIComponent(request.queryKey)}=${encodeURIComponent(request.queryValue)}${randomize}`;
+ let query = `?${encodeURIComponent(request.queryKey)}=`;
+ if (request.queryValue === 'admin' || request.queryValue ===
'operations' || request.queryValue === 'read-only'){
+ query += encodeURIComponent(request.queryValue);
+ }else{
+ query += encodeURIComponent(request.queryValue+randomize);
+ }
const response = await this.getResponse("get", request.route +
query)
-
if (response.status == 200) {
if(request.hasOwnProperty('isArray')){
data[request.replace] = [await
response.data.response[0].id];
diff --git a/traffic_portal/test/integration/Data/prerequisites.ts
b/traffic_portal/test/integration/Data/prerequisites.ts
index 2d7523c..1afd3da 100644
--- a/traffic_portal/test/integration/Data/prerequisites.ts
+++ b/traffic_portal/test/integration/Data/prerequisites.ts
@@ -69,7 +69,7 @@ export const prerequisites = [
fullName: "TPAdmin",
username: "TPAdmin",
email: "@test.com",
- role: 1,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -79,6 +79,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantSame",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "admin",
+ replace: "role"
}
]
},
@@ -86,7 +92,7 @@ export const prerequisites = [
fullName: "TPOperator",
username: "TPOperator",
email: "@test.com",
- role: 2,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -96,6 +102,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantSame",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "operations",
+ replace: "role"
}
]
},
@@ -103,7 +115,7 @@ export const prerequisites = [
fullName: "TPReadOnly",
username: "TPReadOnly",
email: "@test.com",
- role: 3,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -113,6 +125,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantSame",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "read-only",
+ replace: "role"
}
]
},
@@ -120,7 +138,7 @@ export const prerequisites = [
fullName: "TPAdminDiff",
username: "TPAdminDiff",
email: "@test.com",
- role: 1,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -130,6 +148,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantDifferent",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "admin",
+ replace: "role"
}
]
},
@@ -137,7 +161,7 @@ export const prerequisites = [
fullName: "TPOperatorDiff",
username: "TPOperatorDiff",
email: "@test.com",
- role: 2,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -147,6 +171,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantDifferent",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "operations",
+ replace: "role"
}
]
},
@@ -154,7 +184,7 @@ export const prerequisites = [
fullName: "TPReadOnlyDiff",
username: "TPReadOnlyDiff",
email: "@test.com",
- role: 3,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -164,6 +194,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantDifferent",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "read-only",
+ replace: "role"
}
]
},
@@ -171,7 +207,7 @@ export const prerequisites = [
fullName: "TPAdminParent",
username: "TPAdminParent",
email: "@test.com",
- role: 1,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -181,6 +217,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantParent",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "admin",
+ replace: "role"
}
]
},
@@ -188,7 +230,7 @@ export const prerequisites = [
fullName: "TPOperatorParent",
username: "TPOperatorParent",
email: "@test.com",
- role: 2,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -198,6 +240,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantParent",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "operations",
+ replace: "role"
}
]
},
@@ -205,7 +253,7 @@ export const prerequisites = [
fullName: "TPReadOnlyParent",
username: "TPReadOnlyParent",
email: "@test.com",
- role: 3,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -215,6 +263,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantParent",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "read-only",
+ replace: "role"
}
]
},
@@ -222,7 +276,7 @@ export const prerequisites = [
fullName: "TPAdminChild",
username: "TPAdminChild",
email: "@test.com",
- role: 1,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -232,6 +286,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantChild",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "admin",
+ replace: "role"
}
]
},
@@ -239,7 +299,7 @@ export const prerequisites = [
fullName: "TPOperatorChild",
username: "TPOperatorChild",
email: "@test.com",
- role: 2,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -249,6 +309,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantChild",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "operations",
+ replace: "role"
}
]
},
@@ -256,7 +322,7 @@ export const prerequisites = [
fullName: "TPReadOnlyChild",
username: "TPReadOnlyChild",
email: "@test.com",
- role: 3,
+ role: 0,
tenantId: 1,
localPasswd: "pa$$word",
confirmLocalPasswd: "pa$$word",
@@ -266,6 +332,12 @@ export const prerequisites = [
queryKey: "name",
queryValue: "tenantChild",
replace: "tenantId"
+ },
+ {
+ route: "/roles",
+ queryKey: "name",
+ queryValue: "read-only",
+ replace: "role"
}
]
}
