(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestAuthZReq(t *testing.T) { |
| 62 | request := `{"User":"bob","UserAuthNMethod":"","RequestMethod":"POST","RequestURI":"http://127.0.0.1/v.1.23/containers/json","RequestBody":"","RequestHeader":"","RequestStatusCode":""}` |
| 63 | |
| 64 | response, err := http.Post( |
| 65 | "http://localhost:32456/AuthZPlugin.AuthZReq", |
| 66 | sdk.DefaultContentTypeV1_1, |
| 67 | strings.NewReader(request), |
| 68 | ) |
| 69 | if err != nil { |
| 70 | t.Fatal(err) |
| 71 | } |
| 72 | |
| 73 | defer response.Body.Close() |
| 74 | |
| 75 | body, err := io.ReadAll(response.Body) |
| 76 | if err != nil { |
| 77 | t.Fatal(err) |
| 78 | } |
| 79 | |
| 80 | var r Response |
| 81 | if err := json.Unmarshal(body, &r); err != nil { |
| 82 | t.Fatal(err) |
| 83 | } |
| 84 | |
| 85 | if r.Msg != "You are not authorized" { |
| 86 | t.Fatal("Authorization message does not match") |
| 87 | } |
| 88 | |
| 89 | if r.Allow { |
| 90 | t.Fatal("The request has been allowed while should not be") |
| 91 | } |
| 92 | |
| 93 | if r.Err != "" { |
| 94 | t.Fatal("Authorization Error should be empty") |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | func TestAuthZRes(t *testing.T) { |
| 99 | request := `{"User":"bob","UserAuthNMethod":"","RequestMethod":"POST","RequestURI":"http://127.0.0.1/v.1.23/containers/json","RequestBody":"","RequestHeader":"","RequestStatusCode":"", "ResponseBody":"","ResponseHeader":"","ResponseStatusCode":200}` |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…