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

Function TestRevocationWithAdminRoles

rest/revocation_test.go:907–934  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

905}
906
907func TestRevocationWithAdminRoles(t *testing.T) {
908 defer db.SuspendSequenceBatching()()
909
910 rt := NewRestTester(t, &RestTesterConfig{SyncFn: channels.DocChannelsSyncFunction})
911 defer rt.Close()
912
913 resp := rt.SendAdminRequest("PUT", "/db/_role/role", GetRolePayload(t, "", rt.GetSingleDataStore(), []string{"A"}))
914 RequireStatus(t, resp, http.StatusCreated)
915
916 resp = rt.SendAdminRequest("PUT", "/db/_user/user", `{"admin_roles": ["role"], "password": "letmein"}`)
917 RequireStatus(t, resp, http.StatusCreated)
918
919 resp = rt.SendAdminRequest("PUT", "/{{.keyspace}}/doc", `{"channels": ["A"]}`)
920 RequireStatus(t, resp, http.StatusCreated)
921
922 changes := rt.WaitForChanges(2, "/{{.keyspace}}/_changes?since=0&revocations=true", "user", false)
923
924 assert.Equal(t, "doc", changes.Results[1].ID)
925 assert.False(t, changes.Results[1].Revoked)
926
927 resp = rt.SendAdminRequest("PUT", "/db/_user/user", `{"admin_roles": []}`)
928 RequireStatus(t, resp, http.StatusOK)
929
930 changes = rt.WaitForChanges(2, fmt.Sprintf("/{{.keyspace}}/_changes?since=%d&revocations=true", 3), "user", false)
931
932 assert.Equal(t, "doc", changes.Results[0].ID)
933 assert.True(t, changes.Results[0].Revoked)
934}
935
936func TestRevocationMutationMovesIntoRevokedChannel(t *testing.T) {
937 defer db.SuspendSequenceBatching()()

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
SendAdminRequestMethod · 0.95
GetSingleDataStoreMethod · 0.95
WaitForChangesMethod · 0.95
SuspendSequenceBatchingFunction · 0.92
NewRestTesterFunction · 0.85
GetRolePayloadFunction · 0.85
RequireStatusFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected