mirror of
https://github.com/simon987/task_tracker.git
synced 2025-12-13 14:59:03 +00:00
Fix worker permissions bug
This commit is contained in:
@@ -328,7 +328,7 @@ func TestTaskNoAccess(t *testing.T) {
|
||||
Assign: true,
|
||||
Submit: true,
|
||||
}, worker)
|
||||
acceptAccessRequest(worker.Id, pid, testAdminCtx)
|
||||
acceptAccessRequest(pid, worker.Id, testAdminCtx)
|
||||
|
||||
createResp := createTask(api.SubmitTaskRequest{
|
||||
Project: pid,
|
||||
@@ -376,7 +376,7 @@ func TestTaskHasAccess(t *testing.T) {
|
||||
Assign: true,
|
||||
Project: pid,
|
||||
}, worker)
|
||||
acceptAccessRequest(worker.Id, pid, testAdminCtx)
|
||||
acceptAccessRequest(pid, worker.Id, testAdminCtx)
|
||||
|
||||
createResp := createTask(api.SubmitTaskRequest{
|
||||
Project: pid,
|
||||
@@ -817,6 +817,70 @@ func TestTaskReleaseBigInt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskSubmitUnauthorized(t *testing.T) {
|
||||
|
||||
pid := createProjectAsAdmin(api.CreateProjectRequest{
|
||||
Name: "testtasksubmitunauthorized",
|
||||
GitRepo: "testtasksubmitunauthorized",
|
||||
CloneUrl: "testtasksubmitunauthorized",
|
||||
}).Content.Id
|
||||
|
||||
w := genWid()
|
||||
|
||||
requestAccess(api.CreateWorkerAccessRequest{
|
||||
Project: pid,
|
||||
Submit: true,
|
||||
Assign: true,
|
||||
}, w)
|
||||
|
||||
resp := createTask(api.SubmitTaskRequest{
|
||||
Project: pid,
|
||||
Recipe: "ssss",
|
||||
}, w)
|
||||
|
||||
if resp.Ok != false {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskGetUnauthorized(t *testing.T) {
|
||||
|
||||
pid := createProjectAsAdmin(api.CreateProjectRequest{
|
||||
Name: "testtaskgetunauthorized",
|
||||
GitRepo: "testtaskgetunauthorized",
|
||||
CloneUrl: "testtaskgettunauthorized",
|
||||
Hidden: true,
|
||||
}).Content.Id
|
||||
|
||||
w := genWid()
|
||||
wWithAccess := genWid()
|
||||
|
||||
requestAccess(api.CreateWorkerAccessRequest{
|
||||
Project: pid,
|
||||
Submit: true,
|
||||
Assign: true,
|
||||
}, wWithAccess)
|
||||
acceptAccessRequest(pid, wWithAccess.Id, testAdminCtx)
|
||||
|
||||
createTask(api.SubmitTaskRequest{
|
||||
Project: pid,
|
||||
Recipe: "ssss",
|
||||
}, wWithAccess)
|
||||
|
||||
requestAccess(api.CreateWorkerAccessRequest{
|
||||
Project: pid,
|
||||
Submit: true,
|
||||
Assign: true,
|
||||
}, w)
|
||||
|
||||
resp := getTaskFromProject(pid, w)
|
||||
|
||||
fmt.Println(resp.Message)
|
||||
if resp.Ok != false {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
func createTask(request api.SubmitTaskRequest, worker *storage.Worker) (ar api.JsonResponse) {
|
||||
r := Post("/task/submit", request, worker, nil)
|
||||
UnmarshalResponse(r, &ar)
|
||||
|
||||
Reference in New Issue
Block a user