Skip to content

Commit 40f9958

Browse files
Merge tanzu changes
1 parent 1817e39 commit 40f9958

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

selenium/test/mgt-api.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,27 @@ module.exports = {
9090
throw new Error(req.responseText)
9191
}
9292
},
93+
grantPermissions: (url, vhost, user, permissions) => {
94+
log("Granting permissions [" + JSON.stringify(permissions) +
95+
"] for user " + user + " on vhost " + vhost + " on " + url)
96+
97+
const req = new XMLHttpRequest()
98+
let base64Credentials = btoa('administrator-only' + ":" + 'guest')
99+
let finalUrl = url + "/api/permissions/" + encodeURIComponent(vhost) + "/"
100+
+ encodeURIComponent(user)
101+
req.open('PUT', finalUrl, false)
102+
req.setRequestHeader("Authorization", "Basic " + base64Credentials)
103+
req.setRequestHeader('Content-Type', 'application/json')
104+
105+
req.send(JSON.stringify(permissions))
106+
if (req.status == 200 || req.status == 204 || req.status == 201) {
107+
log("Succesfully granted permissions")
108+
return
109+
}else {
110+
error("status:" + req.status + " : " + req.responseText)
111+
throw new Error(req.responseText)
112+
}
113+
},
93114
deleteVhost: (url, vhost) => {
94115
log("Deleting vhost " + vhost)
95116
const req = new XMLHttpRequest()

0 commit comments

Comments
 (0)