put doc in multiple channels, remove from some channels, assert response gets right sequences for each channels
(t *testing.T)
| 650 | |
| 651 | // put doc in multiple channels, remove from some channels, assert response gets right sequences for each channels |
| 652 | func TestGetUserDocAccessMultiChannel(t *testing.T) { |
| 653 | rt := NewRestTester(t, &RestTesterConfig{SyncFn: `function(doc) {channel(doc.channel);}`}) |
| 654 | defer rt.Close() |
| 655 | userGrant := userGrant{ |
| 656 | user: "alice", |
| 657 | adminChannels: map[string][]string{ |
| 658 | "{{.keyspace}}": {"A", "B", "C"}, |
| 659 | }, |
| 660 | } |
| 661 | userGrant.request(rt) |
| 662 | |
| 663 | version := rt.PutDoc("doc1", `{"channel":["A"]}`) |
| 664 | updatedVersion := rt.UpdateDoc("doc1", version, `{"channel":["B", "A"]}`) |
| 665 | updatedVersion = rt.UpdateDoc("doc1", updatedVersion, `{"channel":["C", "B"]}`) |
| 666 | |
| 667 | // assert sequences are registered correctly |
| 668 | expectedOutput := `{"doc1": {"A": { "entries" : ["2-4"]}, "B": { "entries" : ["3-0"]}, "C": { "entries" : ["4-0"]} }}` |
| 669 | response := rt.SendDiagnosticRequest(http.MethodGet, |
| 670 | "/{{.keyspace}}/_user/alice?docids=doc1", ``) |
| 671 | RequireStatus(rt.TB(), response, http.StatusOK) |
| 672 | require.JSONEq(rt.TB(), rt.mustTemplateResource(expectedOutput), response.BodyString()) |
| 673 | |
| 674 | // remove all channels |
| 675 | _ = rt.UpdateDoc("doc1", updatedVersion, `{"channel":[]}`) |
| 676 | |
| 677 | // assert sequences spans end here |
| 678 | expectedOutput = `{"doc1": {"A": { "entries" : ["2-4"]}, "B": { "entries" : ["3-5"]}, "C": { "entries" : ["4-5"]} }}` |
| 679 | response = rt.SendDiagnosticRequest(http.MethodGet, |
| 680 | "/{{.keyspace}}/_user/alice?docids=doc1", ``) |
| 681 | RequireStatus(rt.TB(), response, http.StatusOK) |
| 682 | require.JSONEq(rt.TB(), rt.mustTemplateResource(expectedOutput), response.BodyString()) |
| 683 | } |
| 684 | |
| 685 | // give user access to chanA through admin API and role, remove admin API assignment, and assert access span is admin assignment to 0 |
| 686 | func TestGetUserDocAccessContinuousRoleAdminAPI(t *testing.T) { |
nothing calls this directly
no test coverage detected