MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / TestAdminMeta

Function TestAdminMeta

internal/integration_tests/admin_meta_test.go:17–48  ·  view source on GitHub ↗

TestAdminMeta tests the _admin_meta query, the non-deprecated source of the configured roles for the dashboard. It must be super-admin gated and return the configured role lists.

(t *testing.T)

Source from the content-addressed store, hash-verified

15// configured roles for the dashboard. It must be super-admin gated and return
16// the configured role lists.
17func TestAdminMeta(t *testing.T) {
18 cfg := getTestConfig()
19 ts := initTestSetup(t, cfg)
20 req, ctx := createContext(ts)
21
22 t.Run("should fail without admin cookie", func(t *testing.T) {
23 res, err := ts.GraphQLProvider.AdminMeta(ctx)
24 assert.Error(t, err)
25 assert.Nil(t, res)
26 })
27
28 t.Run("should return configured roles with a valid admin cookie", func(t *testing.T) {
29 _, err := ts.GraphQLProvider.AdminLogin(ctx, &model.AdminLoginRequest{
30 AdminSecret: cfg.AdminSecret,
31 })
32 require.NoError(t, err)
33
34 h, err := crypto.EncryptPassword(cfg.AdminSecret)
35 require.NoError(t, err)
36 req.Header.Set("Cookie", fmt.Sprintf("%s=%s", constants.AdminCookieName, h))
37
38 res, err := ts.GraphQLProvider.AdminMeta(ctx)
39 require.NoError(t, err)
40 require.NotNil(t, res)
41 // Mirrors the configured roles in getTestConfig.
42 assert.Equal(t, cfg.Roles, res.Roles)
43 assert.Equal(t, cfg.DefaultRoles, res.DefaultRoles)
44 assert.Contains(t, res.Roles, "admin")
45 // Non-null list contract: never nil, even when nothing is configured.
46 assert.NotNil(t, res.ProtectedRoles)
47 })
48}

Callers

nothing calls this directly

Calls 9

EncryptPasswordFunction · 0.92
getTestConfigFunction · 0.85
initTestSetupFunction · 0.85
createContextFunction · 0.85
ErrorMethod · 0.80
AdminMetaMethod · 0.65
AdminLoginMethod · 0.65
SetMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected