MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestInitRole

Function TestInitRole

auth/role_test.go:25–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestInitRole(t *testing.T) {
26 base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth)
27 // Check initializing role with legal role name.
28 role := &roleImpl{}
29 assert.NoError(t, role.initRole("Music", channels.BaseSetOf(t, "Spotify", "Youtube"), nil))
30 assert.Equal(t, "Music", role.Name_)
31 assert.Equal(t, channels.TimedSet{
32 "Spotify": channels.NewVbSimpleSequence(0x1),
33 "Youtube": channels.NewVbSimpleSequence(0x1)}, role.ExplicitChannels_)
34
35 // Check initializing role with illegal role name.
36 role = &roleImpl{}
37 assert.Error(t, role.initRole("Music/", channels.BaseSetOf(t, "Spotify", "Youtube"), nil))
38 assert.Error(t, role.initRole("Music:", channels.BaseSetOf(t, "Spotify", "Youtube"), nil))
39 assert.Error(t, role.initRole("Music,", channels.BaseSetOf(t, "Spotify", "Youtube"), nil))
40 assert.Error(t, role.initRole(".", channels.BaseSetOf(t, "Spotify", "Youtube"), nil))
41 assert.Error(t, role.initRole("\xf7,", channels.BaseSetOf(t, "Spotify", "Youtube"), nil))
42}
43
44func TestAuthorizeChannelsRole(t *testing.T) {
45 ctx := base.TestCtx(t)

Callers

nothing calls this directly

Calls 6

initRoleMethod · 0.95
SetUpTestLoggingFunction · 0.92
BaseSetOfFunction · 0.92
NewVbSimpleSequenceFunction · 0.92
EqualMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected