Skip to content

Commit fb9878d

Browse files
committed
ROX-11101: Remove deprecated resource types from central
1 parent 0c5e706 commit fb9878d

File tree

129 files changed

+300
-620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+300
-620
lines changed

central/activecomponent/updater/updater_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525

2626
updaterCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
2727
sac.AllowFixedScopes(sac.AccessModeScopeKeys(storage.Access_READ_ACCESS, storage.Access_READ_WRITE_ACCESS),
28-
sac.ResourceScopeKeys(resources.Deployment, resources.Image, resources.Indicator)))
28+
sac.ResourceScopeKeys(resources.Deployment, resources.Image, resources.DeploymentExtension)))
2929
)
3030

3131
type updaterImpl struct {

central/apitoken/backend/singleton.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func Singleton() Backend {
2929
ctx := sac.WithGlobalAccessScopeChecker(context.Background(),
3030
sac.AllowFixedScopes(
3131
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS, storage.Access_READ_WRITE_ACCESS),
32-
sac.ResourceScopeKeys(resources.APIToken)))
32+
sac.ResourceScopeKeys(resources.Integration)))
3333

3434
// Create and initialize source.
3535
src := newSource()

central/apitoken/datastore/datastore_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
var (
15-
apiTokenSAC = sac.ForResource(resources.APIToken)
15+
apiTokenSAC = sac.ForResource(resources.Integration)
1616
)
1717

1818
type datastoreImpl struct {

central/apitoken/datastore/datastore_test.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ type apiTokenDataStoreTestSuite struct {
2424
hasReadCtx context.Context
2525
hasWriteCtx context.Context
2626

27-
hasReadIntegrationCtx context.Context
28-
hasWriteIntegrationCtx context.Context
29-
3027
dataStore DataStore
3128
storage *storeMocks.MockStore
3229

@@ -36,19 +33,10 @@ type apiTokenDataStoreTestSuite struct {
3633
func (s *apiTokenDataStoreTestSuite) SetupTest() {
3734
s.hasNoneCtx = sac.WithGlobalAccessScopeChecker(context.Background(), sac.DenyAllAccessScopeChecker())
3835
s.hasReadCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
39-
sac.AllowFixedScopes(
40-
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS),
41-
sac.ResourceScopeKeys(resources.APIToken)))
42-
s.hasWriteCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
43-
sac.AllowFixedScopes(
44-
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS, storage.Access_READ_WRITE_ACCESS),
45-
sac.ResourceScopeKeys(resources.APIToken)))
46-
47-
s.hasReadIntegrationCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
4836
sac.AllowFixedScopes(
4937
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS),
5038
sac.ResourceScopeKeys(resources.Integration)))
51-
s.hasWriteIntegrationCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
39+
s.hasWriteCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
5240
sac.AllowFixedScopes(
5341
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS, storage.Access_READ_WRITE_ACCESS),
5442
sac.ResourceScopeKeys(resources.Integration)))
@@ -67,10 +55,6 @@ func (s *apiTokenDataStoreTestSuite) TestAddToken() {
6755
s.storage.EXPECT().Upsert(gomock.Any(), token).Return(nil).MaxTimes(2)
6856

6957
s.NoError(s.dataStore.AddToken(s.hasWriteCtx, token))
70-
71-
token.Id = "id2"
72-
73-
s.NoError(s.dataStore.AddToken(s.hasWriteIntegrationCtx, token))
7458
}
7559

7660
func (s *apiTokenDataStoreTestSuite) TestGetTokenOrNil() {
@@ -81,19 +65,11 @@ func (s *apiTokenDataStoreTestSuite) TestGetTokenOrNil() {
8165
s.NoError(err)
8266
s.Nil(token)
8367

84-
token, err = s.dataStore.GetTokenOrNil(s.hasReadIntegrationCtx, "id")
85-
s.NoError(err)
86-
s.Nil(token)
87-
8868
s.storage.EXPECT().Get(gomock.Any(), "id").Return(expectedToken, true, nil).MaxTimes(2)
8969

9070
token, err = s.dataStore.GetTokenOrNil(s.hasReadCtx, "id")
9171
s.NoError(err)
9272
s.Equal(expectedToken, token)
93-
94-
token, err = s.dataStore.GetTokenOrNil(s.hasReadIntegrationCtx, "id")
95-
s.NoError(err)
96-
s.Equal(expectedToken, token)
9773
}
9874

9975
func (s *apiTokenDataStoreTestSuite) TestRevokeToken() {
@@ -104,19 +80,11 @@ func (s *apiTokenDataStoreTestSuite) TestRevokeToken() {
10480
s.NoError(err)
10581
s.False(exists)
10682

107-
exists, err = s.dataStore.RevokeToken(s.hasWriteIntegrationCtx, "id")
108-
s.NoError(err)
109-
s.False(exists)
110-
11183
s.storage.EXPECT().Get(gomock.Any(), "id").Return(expectedToken, true, nil).MaxTimes(2)
11284
expectedToken.Revoked = true
11385
s.storage.EXPECT().Upsert(gomock.Any(), expectedToken).Return(nil).MaxTimes(2)
11486

11587
exists, err = s.dataStore.RevokeToken(s.hasWriteCtx, "id")
11688
s.NoError(err)
11789
s.True(exists)
118-
119-
exists, err = s.dataStore.RevokeToken(s.hasWriteIntegrationCtx, "id")
120-
s.NoError(err)
121-
s.True(exists)
12290
}

central/apitoken/service/service_impl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import (
2424

2525
var (
2626
authorizer = perrpc.FromMap(map[authz.Authorizer][]string{
27-
user.With(permissions.View(resources.APIToken)): {
27+
user.With(permissions.View(resources.Integration)): {
2828
"/v1.APITokenService/GetAPIToken",
2929
"/v1.APITokenService/GetAPITokens",
3030
},
31-
user.With(permissions.Modify(resources.APIToken)): {
31+
user.With(permissions.Modify(resources.Integration)): {
3232
"/v1.APITokenService/GenerateToken",
3333
"/v1.APITokenService/RevokeToken",
3434
},

central/authprovider/datastore/datastore_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
var (
17-
authProviderSAC = sac.ForResource(resources.AuthProvider)
17+
authProviderSAC = sac.ForResource(resources.Access)
1818
)
1919

2020
type datastoreImpl struct {

central/authprovider/datastore/datastore_impl_test.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ func (s *authProviderDataStoreEnforceTestSuite) SetupTest() {
3838
s.hasReadCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
3939
sac.AllowFixedScopes(
4040
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS),
41-
sac.ResourceScopeKeys(resources.AuthProvider)))
41+
sac.ResourceScopeKeys(resources.Access)))
4242
s.hasWriteCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
4343
sac.AllowFixedScopes(
4444
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS, storage.Access_READ_WRITE_ACCESS),
45-
sac.ResourceScopeKeys(resources.AuthProvider)))
45+
sac.ResourceScopeKeys(resources.Access)))
4646

4747
s.mockCtrl = gomock.NewController(s.T())
4848
s.storage = storeMocks.NewMockStore(s.mockCtrl)
@@ -97,8 +97,6 @@ type authProviderDataStoreTestSuite struct {
9797
hasReadCtx context.Context
9898
hasWriteCtx context.Context
9999

100-
hasWriteAccessCtx context.Context
101-
102100
storage *storeMocks.MockStore
103101
dataStore authproviders.Store
104102

@@ -110,12 +108,8 @@ func (s *authProviderDataStoreTestSuite) SetupTest() {
110108
s.hasReadCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
111109
sac.AllowFixedScopes(
112110
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS),
113-
sac.ResourceScopeKeys(resources.AuthProvider)))
111+
sac.ResourceScopeKeys(resources.Access)))
114112
s.hasWriteCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
115-
sac.AllowFixedScopes(
116-
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS, storage.Access_READ_WRITE_ACCESS),
117-
sac.ResourceScopeKeys(resources.AuthProvider)))
118-
s.hasWriteAccessCtx = sac.WithGlobalAccessScopeChecker(context.Background(),
119113
sac.AllowFixedScopes(
120114
sac.AccessModeScopeKeys(storage.Access_READ_ACCESS, storage.Access_READ_WRITE_ACCESS),
121115
sac.ResourceScopeKeys(resources.Access)))
@@ -136,9 +130,6 @@ func (s *authProviderDataStoreTestSuite) TestAllowsAdd() {
136130

137131
err := s.dataStore.AddAuthProvider(s.hasWriteCtx, &storage.AuthProvider{})
138132
s.NoError(err, "expected no error trying to write with permissions")
139-
140-
err = s.dataStore.AddAuthProvider(s.hasWriteAccessCtx, &storage.AuthProvider{})
141-
s.NoError(err, "expected no error trying to write with Access permission")
142133
}
143134

144135
func (s *authProviderDataStoreTestSuite) TestErrorOnAdd() {
@@ -154,9 +145,6 @@ func (s *authProviderDataStoreTestSuite) TestAllowsUpdate() {
154145

155146
err := s.dataStore.UpdateAuthProvider(s.hasWriteCtx, &storage.AuthProvider{})
156147
s.NoError(err, "expected no error trying to write with permissions")
157-
158-
err = s.dataStore.UpdateAuthProvider(s.hasWriteAccessCtx, &storage.AuthProvider{})
159-
s.NoError(err, "expected no error trying to write with Access permission")
160148
}
161149

162150
func (s *authProviderDataStoreTestSuite) TestErrorOnUpdate() {
@@ -172,9 +160,6 @@ func (s *authProviderDataStoreTestSuite) TestAllowsRemove() {
172160

173161
err := s.dataStore.RemoveAuthProvider(s.hasWriteCtx, "id", false)
174162
s.NoError(err, "expected no error trying to write with permissions")
175-
176-
err = s.dataStore.RemoveAuthProvider(s.hasWriteAccessCtx, "id", false)
177-
s.NoError(err, "expect no error trying to write with Access permissions")
178163
}
179164

180165
func (s *authProviderDataStoreTestSuite) TestUpdateMutableToImmutable() {

central/authprovider/datastore/internal/store/postgres/store.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

central/authprovider/service/service_impl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ var (
3232
"/v1.AuthProviderService/GetLoginAuthProviders",
3333
"/v1.AuthProviderService/ExchangeToken",
3434
},
35-
user.With(permissions.View(resources.AuthProvider)): {
35+
user.With(permissions.View(resources.Access)): {
3636
"/v1.AuthProviderService/GetAuthProvider",
3737
"/v1.AuthProviderService/GetAuthProviders",
3838
},
39-
user.With(permissions.Modify(resources.AuthProvider)): {
39+
user.With(permissions.Modify(resources.Access)): {
4040
"/v1.AuthProviderService/PostAuthProvider",
4141
"/v1.AuthProviderService/UpdateAuthProvider",
4242
"/v1.AuthProviderService/PutAuthProvider",

central/certgen/service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ func (s *serviceImpl) CustomRoutes() []routes.CustomRoute {
3636
return []routes.CustomRoute{
3737
{
3838
Route: "/api/extensions/certgen/central",
39-
Authorizer: user.With(permissions.Modify(resources.ServiceIdentity)),
39+
Authorizer: user.With(permissions.Modify(resources.Administration)),
4040
ServerHandler: http.HandlerFunc(s.centralHandler),
4141
Compression: false,
4242
},
4343
{
4444
Route: "/api/extensions/certgen/scanner",
45-
Authorizer: user.With(permissions.Modify(resources.ServiceIdentity)),
45+
Authorizer: user.With(permissions.Modify(resources.Administration)),
4646
ServerHandler: http.HandlerFunc(s.scannerHandler),
4747
Compression: false,
4848
},
4949

5050
{
5151
Route: "/api/extensions/certgen/cluster",
52-
Authorizer: user.With(permissions.Modify(resources.ServiceIdentity)),
52+
Authorizer: user.With(permissions.Modify(resources.Administration)),
5353
ServerHandler: http.HandlerFunc(s.securedClusterHandler),
5454
Compression: false,
5555
},

0 commit comments

Comments
 (0)