@@ -69,7 +69,7 @@ describe('plugin-endpoint', () => {
69
69
expect ( policiesMetadata . length ) . toEqual ( 0 ) ;
70
70
} ) ;
71
71
72
- it ( 'should return non empty plugin policies list' , async ( ) => {
72
+ it ( 'should return non empty plugin policies list with resourced permission ' , async ( ) => {
73
73
backendPluginIDsProviderMock . getPluginIds . mockReturnValue ( [ 'permission' ] ) ;
74
74
75
75
mockUrlReaderService . readUrl . mockReturnValue ( mockReadUrlResponse ) ;
@@ -89,22 +89,19 @@ describe('plugin-endpoint', () => {
89
89
expect ( policiesMetadata [ 0 ] . pluginId ) . toEqual ( 'permission' ) ;
90
90
expect ( policiesMetadata [ 0 ] . policies ) . toEqual ( [
91
91
{
92
+ isResourced : true ,
92
93
permission : 'policy-entity' ,
93
94
policy : 'read' ,
94
95
} ,
95
- {
96
- permission : 'policy.entity.read' ,
97
- policy : 'read' ,
98
- } ,
99
96
] ) ;
100
97
} ) ;
101
98
102
- it ( 'should return plugin policies list without resource type permissions ' , async ( ) => {
99
+ it ( 'should return non empty plugin policies list with non resourced permission ' , async ( ) => {
103
100
backendPluginIDsProviderMock . getPluginIds . mockReturnValue ( [ 'permission' ] ) ;
104
101
105
102
mockUrlReaderService . readUrl . mockReturnValue ( mockReadUrlResponse ) ;
106
103
bufferMock . toString . mockReturnValueOnce (
107
- '{"permissions":[{"type":"resource ","name":"policy .entity.read ","attributes":{"action":"read "}}]}' ,
104
+ '{"permissions":[{"type":"basic ","name":"catalog .entity.create ","attributes":{"action":"create "}}]}' ,
108
105
) ;
109
106
110
107
const collector = new PluginPermissionMetadataCollector (
@@ -119,8 +116,9 @@ describe('plugin-endpoint', () => {
119
116
expect ( policiesMetadata [ 0 ] . pluginId ) . toEqual ( 'permission' ) ;
120
117
expect ( policiesMetadata [ 0 ] . policies ) . toEqual ( [
121
118
{
122
- permission : 'policy.entity.read' ,
123
- policy : 'read' ,
119
+ isResourced : false ,
120
+ permission : 'catalog.entity.create' ,
121
+ policy : 'create' ,
124
122
} ,
125
123
] ) ;
126
124
} ) ;
@@ -143,7 +141,7 @@ describe('plugin-endpoint', () => {
143
141
throw new NotFoundError ( ) ;
144
142
} ) ;
145
143
bufferMock . toString . mockReturnValueOnce (
146
- '{"permissions":[{"type":"resource","name":"policy.entity.read","attributes":{"action":"read"}}]}' ,
144
+ '{"permissions":[{"type":"resource","resourceType":"policy-entity"," name":"policy.entity.read","attributes":{"action":"read"}}]}' ,
147
145
) ;
148
146
149
147
const collector = new PluginPermissionMetadataCollector (
@@ -158,7 +156,8 @@ describe('plugin-endpoint', () => {
158
156
expect ( policiesMetadata [ 0 ] . pluginId ) . toEqual ( 'permission' ) ;
159
157
expect ( policiesMetadata [ 0 ] . policies ) . toEqual ( [
160
158
{
161
- permission : 'policy.entity.read' ,
159
+ isResourced : true ,
160
+ permission : 'policy-entity' ,
162
161
policy : 'read' ,
163
162
} ,
164
163
] ) ;
@@ -182,7 +181,7 @@ describe('plugin-endpoint', () => {
182
181
throw new Error ( 'Unexpected error' ) ;
183
182
} ) ;
184
183
bufferMock . toString . mockReturnValueOnce (
185
- '{"permissions":[{"type":"resource","name":"policy.entity.read","attributes":{"action":"read"}}]}' ,
184
+ '{"permissions":[{"type":"resource","resourceType":"policy-entity"," name":"policy.entity.read","attributes":{"action":"read"}}]}' ,
186
185
) ;
187
186
188
187
const errorSpy = jest . spyOn ( logger , 'error' ) . mockClear ( ) ;
@@ -199,7 +198,8 @@ describe('plugin-endpoint', () => {
199
198
expect ( policiesMetadata [ 0 ] . pluginId ) . toEqual ( 'permission' ) ;
200
199
expect ( policiesMetadata [ 0 ] . policies ) . toEqual ( [
201
200
{
202
- permission : 'policy.entity.read' ,
201
+ isResourced : true ,
202
+ permission : 'policy-entity' ,
203
203
policy : 'read' ,
204
204
} ,
205
205
] ) ;
@@ -222,7 +222,7 @@ describe('plugin-endpoint', () => {
222
222
} ) ;
223
223
bufferMock . toString
224
224
. mockReturnValueOnce (
225
- '{"permissions":[{"type":"resource","name":"policy.entity.read","attributes":{"action":"read"}}]}' ,
225
+ '{"permissions":[{"type":"resource","resourceType":"policy-entity"," name":"policy.entity.read","attributes":{"action":"read"}}]}' ,
226
226
)
227
227
. mockReturnValueOnce ( 'non json data' ) ;
228
228
@@ -240,7 +240,8 @@ describe('plugin-endpoint', () => {
240
240
expect ( policiesMetadata [ 0 ] . pluginId ) . toEqual ( 'permission' ) ;
241
241
expect ( policiesMetadata [ 0 ] . policies ) . toEqual ( [
242
242
{
243
- permission : 'policy.entity.read' ,
243
+ isResourced : true ,
244
+ permission : 'policy-entity' ,
244
245
policy : 'read' ,
245
246
} ,
246
247
] ) ;
0 commit comments