(t *testing.T)
| 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}` |
| 100 | |
| 101 | response, err := http.Post( |
| 102 | "http://localhost:32456/AuthZPlugin.AuthZRes", |
| 103 | sdk.DefaultContentTypeV1_1, |
| 104 | strings.NewReader(request), |
| 105 | ) |
| 106 | if err != nil { |
| 107 | t.Fatal(err) |
| 108 | } |
| 109 | |
| 110 | defer response.Body.Close() |
| 111 | |
| 112 | body, err := io.ReadAll(response.Body) |
| 113 | if err != nil { |
| 114 | t.Fatal(err) |
| 115 | } |
| 116 | |
| 117 | var r Response |
| 118 | if err := json.Unmarshal(body, &r); err != nil { |
| 119 | t.Fatal(err) |
| 120 | } |
| 121 | |
| 122 | if r.Msg != "You are not authorized" { |
| 123 | t.Fatal("Authorization message does not match") |
| 124 | } |
| 125 | |
| 126 | if r.Allow { |
| 127 | t.Fatal("The request has been allowed while should not be") |
| 128 | } |
| 129 | |
| 130 | if r.Err != "" { |
| 131 | t.Fatal("Authorization Error should be empty") |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | func TestPeerCertificateMarshalJSON(t *testing.T) { |
| 136 | template := &x509.Certificate{ |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…