(t *testing.T)
| 19 | } |
| 20 | |
| 21 | func TestCheckScimError(t *testing.T) { |
| 22 | for _, test := range []struct { |
| 23 | statusCode int |
| 24 | method string |
| 25 | applicable bool |
| 26 | }{ |
| 27 | // valid status + method |
| 28 | {307, http.MethodGet, true}, |
| 29 | {308, http.MethodDelete, true}, |
| 30 | {400, http.MethodPut, true}, |
| 31 | {401, http.MethodPatch, true}, |
| 32 | {403, http.MethodPost, true}, |
| 33 | {404, http.MethodGet, true}, |
| 34 | {500, http.MethodDelete, false}, |
| 35 | {501, http.MethodPut, true}, |
| 36 | |
| 37 | // invalid method |
| 38 | {400, http.MethodConnect, false}, |
| 39 | {400, http.MethodHead, false}, |
| 40 | {400, http.MethodOptions, false}, |
| 41 | {400, http.MethodTrace, false}, |
| 42 | |
| 43 | // invalid combination |
| 44 | {409, http.MethodGet, false}, |
| 45 | {412, http.MethodGet, false}, |
| 46 | {412, http.MethodPost, false}, |
| 47 | {413, http.MethodGet, false}, |
| 48 | {413, http.MethodDelete, false}, |
| 49 | {413, http.MethodPut, false}, |
| 50 | {413, http.MethodPatch, false}, |
| 51 | } { |
| 52 | err := CheckScimError(ScimError{ |
| 53 | Status: test.statusCode, |
| 54 | }, test.method) |
| 55 | if test.applicable { |
| 56 | if err.Status == 500 { |
| 57 | t.Error("no status code 500 expected") |
| 58 | } |
| 59 | } else { |
| 60 | if err.Status != 500 { |
| 61 | t.Errorf("status code 500 expected, got %d", err.Status) |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func TestScimErrorMarshalling(t *testing.T) { |
| 68 | scimErr := ScimError{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…