(t *testing.T)
| 997 | } |
| 998 | |
| 999 | func TestNewlyCreateSGWPermissions(t *testing.T) { |
| 1000 | if base.UnitTestUrlIsWalrus() { |
| 1001 | t.Skip("This test only works against Couchbase Server") |
| 1002 | } |
| 1003 | base.TestsRequireMobileRBAC(t) |
| 1004 | mobileSyncGateway := "mobile_sync_gateway" |
| 1005 | syncGatewayDevOps := "sync_gateway_dev_ops" |
| 1006 | syncGatewayApp := "sync_gateway_app" |
| 1007 | syncGatewayAppRo := "sync_gateway_app_ro" |
| 1008 | syncGatewayConfigurator := "sync_gateway_configurator" |
| 1009 | syncGatewayReplicator := "sync_gateway_replicator" |
| 1010 | |
| 1011 | rt := NewRestTester(t, &RestTesterConfig{ |
| 1012 | AdminInterfaceAuthentication: true, |
| 1013 | enableAdminAuthPermissionsCheck: true, |
| 1014 | }) |
| 1015 | defer rt.Close() |
| 1016 | |
| 1017 | bucketName := rt.Bucket().GetName() |
| 1018 | |
| 1019 | eps, httpClient, err := rt.ServerContext().ObtainManagementEndpointsAndHTTPClient() |
| 1020 | require.NoError(t, err) |
| 1021 | |
| 1022 | MakeUser(t, httpClient, eps[0], mobileSyncGateway, "password", []string{fmt.Sprintf("%s[*]", mobileSyncGateway)}) |
| 1023 | defer DeleteUser(t, httpClient, eps[0], mobileSyncGateway) |
| 1024 | MakeUser(t, httpClient, eps[0], syncGatewayDevOps, "password", []string{syncGatewayDevOps}) |
| 1025 | defer DeleteUser(t, httpClient, eps[0], syncGatewayDevOps) |
| 1026 | MakeUser(t, httpClient, eps[0], syncGatewayApp, "password", []string{fmt.Sprintf("%s[*]", syncGatewayApp)}) |
| 1027 | defer DeleteUser(t, httpClient, eps[0], syncGatewayApp) |
| 1028 | MakeUser(t, httpClient, eps[0], syncGatewayAppRo, "password", []string{fmt.Sprintf("%s[*]", syncGatewayAppRo)}) |
| 1029 | defer DeleteUser(t, httpClient, eps[0], syncGatewayAppRo) |
| 1030 | MakeUser(t, httpClient, eps[0], syncGatewayConfigurator, "password", []string{fmt.Sprintf("%s[*]", syncGatewayConfigurator)}) |
| 1031 | defer DeleteUser(t, httpClient, eps[0], syncGatewayConfigurator) |
| 1032 | MakeUser(t, httpClient, eps[0], syncGatewayReplicator, "password", []string{fmt.Sprintf("%s[*]", syncGatewayReplicator)}) |
| 1033 | defer DeleteUser(t, httpClient, eps[0], syncGatewayReplicator) |
| 1034 | |
| 1035 | testUsers := []string{syncGatewayDevOps, syncGatewayApp, syncGatewayAppRo, syncGatewayReplicator, syncGatewayConfigurator} |
| 1036 | |
| 1037 | endPoints := []struct { |
| 1038 | Method string |
| 1039 | Endpoint string |
| 1040 | Users []string |
| 1041 | }{ |
| 1042 | { |
| 1043 | Method: "GET", |
| 1044 | Endpoint: "/db/", |
| 1045 | Users: []string{syncGatewayDevOps, syncGatewayConfigurator}, |
| 1046 | }, |
| 1047 | { |
| 1048 | Method: "POST", |
| 1049 | Endpoint: "/db/", |
| 1050 | Users: []string{syncGatewayApp}, |
| 1051 | }, |
| 1052 | { |
| 1053 | Method: "GET", |
| 1054 | Endpoint: "/db/_all_docs", |
| 1055 | Users: []string{syncGatewayApp, syncGatewayAppRo}, |
| 1056 | }, |
nothing calls this directly
no test coverage detected