-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathadmin_nodb_test.go
More file actions
89 lines (82 loc) · 2.53 KB
/
admin_nodb_test.go
File metadata and controls
89 lines (82 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package httpserver
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestAdmin_PlatformSettings_Unauthorized(t *testing.T) {
h := NewHandler(Deps{Pool: nil, JWTSigner: nil})
for _, p := range []struct {
path string
method string
}{
{"/api/v1/settings/platform", http.MethodGet},
{"/api/v1/settings/platform", http.MethodPut},
} {
srr := httptest.NewRecorder()
r := httptest.NewRequest(p.method, p.path, nil)
h.ServeHTTP(srr, r)
if srr.Code != http.StatusUnauthorized {
t.Fatalf("platform %s %s: %d", p.method, p.path, srr.Code)
}
}
}
func TestAdmin_OIDCList_Unauthorized(t *testing.T) {
h := NewHandler(Deps{Pool: nil, JWTSigner: nil})
rr := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/api/v1/admin/oidc/providers", nil)
h.ServeHTTP(rr, r)
if rr.Code != http.StatusUnauthorized {
t.Fatalf("oidc: %d", rr.Code)
}
}
func TestAdmin_SAMLGet_Unauthorized(t *testing.T) {
h := NewHandler(Deps{Pool: nil, JWTSigner: nil})
rr := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/api/v1/admin/saml/config", nil)
h.ServeHTTP(rr, r)
if rr.Code != http.StatusUnauthorized {
t.Fatalf("saml: %d", rr.Code)
}
}
func TestAdmin_SettingsAI_Unauthorized(t *testing.T) {
h := NewHandler(Deps{Pool: nil, JWTSigner: nil})
for _, p := range []struct {
path string
method string
}{
{"/api/v1/settings/ai", http.MethodGet},
{"/api/v1/settings/ai/models?kind=text", http.MethodGet},
} {
srr := httptest.NewRecorder()
r := httptest.NewRequest(p.method, p.path, nil)
h.ServeHTTP(srr, r)
if srr.Code != http.StatusUnauthorized {
t.Fatalf("settings AI %s %s: %d", p.method, p.path, srr.Code)
}
}
}
func TestAdmin_LTIRegistrationsList_Unauthorized(t *testing.T) {
h := NewHandler(Deps{Pool: nil, JWTSigner: nil})
rr := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/api/v1/admin/lti/registrations", nil)
h.ServeHTTP(rr, r)
if rr.Code != http.StatusUnauthorized {
t.Fatalf("lti registrations: %d", rr.Code)
}
}
func TestNewHandler_AdminRoutesRegistered(t *testing.T) {
h := NewHandler(Deps{Pool: nil, JWTSigner: nil})
rr := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/api/v1/admin/users/00000000-0000-0000-0000-000000000001/dsar-export", nil)
h.ServeHTTP(rr, r)
if rr.Code != http.StatusUnauthorized {
t.Fatalf("dsar: %d", rr.Code)
}
rr = httptest.NewRecorder()
r = httptest.NewRequest(http.MethodPost, "/api/v1/admin/jobs/irt-calibrate", nil)
h.ServeHTTP(rr, r)
if rr.Code != http.StatusUnauthorized {
t.Fatalf("irt: %d", rr.Code)
}
}