Skip to content

Commit 4d914e0

Browse files
SiddharthMantrielasticmachinejeramysoucykibanamachine
authored
[Write restricted dashboards] Change AccessMode const (elastic#239973)
Closes elastic#237816 PR changes the `read_only` const we've been using to `write_restricted`. We've also changed the integration and unit test descriptions to match this. No functional changes here. --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: “jeramysoucy” <[email protected]> Co-authored-by: kibanamachine <[email protected]>
1 parent 48765b8 commit 4d914e0

File tree

25 files changed

+422
-388
lines changed

25 files changed

+422
-388
lines changed

.buildkite/ftr_platform_stateful_configs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ enabled:
332332
- x-pack/platform/test/spaces_api_integration/security_and_spaces/config_basic.ts
333333
- x-pack/platform/test/spaces_api_integration/security_and_spaces/config_trial.ts
334334
- x-pack/platform/test/spaces_api_integration/spaces_only/config.ts
335-
- x-pack/platform/test/spaces_api_integration/read_only_objects/config.ts
335+
- x-pack/platform/test/spaces_api_integration/access_control_objects/config.ts
336336
- x-pack/platform/test/task_manager_claimer_update_by_query/config.ts
337337
- x-pack/platform/test/ui_capabilities/security_and_spaces/config.ts
338338
- x-pack/platform/test/ui_capabilities/spaces_only/config.ts

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"@hapi/wreck": "^18.1.0",
165165
"@hello-pangea/dnd": "18.0.1",
166166
"@kbn/aad-fixtures-plugin": "link:x-pack/platform/test/alerting_api_integration/common/plugins/aad",
167+
"@kbn/access-control-test-plugin": "link:x-pack/platform/test/spaces_api_integration/common/plugins/access_control_test_plugin",
167168
"@kbn/actions-plugin": "link:x-pack/platform/plugins/shared/actions",
168169
"@kbn/actions-simulators-plugin": "link:x-pack/platform/test/alerting_api_integration/common/plugins/actions_simulators",
169170
"@kbn/actions-types": "link:src/platform/packages/shared/kbn-actions-types",
@@ -824,7 +825,6 @@
824825
"@kbn/react-kibana-context-theme": "link:src/platform/packages/shared/react/kibana_context/theme",
825826
"@kbn/react-kibana-mount": "link:src/platform/packages/shared/react/kibana_mount",
826827
"@kbn/react-mute-legacy-root-warning": "link:src/platform/packages/private/kbn-react-mute-legacy-root-warning",
827-
"@kbn/read-only-objects-test-plugin": "link:x-pack/platform/test/spaces_api_integration/common/plugins/read_only_objects_test_plugin",
828828
"@kbn/recently-accessed": "link:src/platform/packages/shared/kbn-recently-accessed",
829829
"@kbn/reindex-service-plugin": "link:x-pack/platform/plugins/private/reindex_service",
830830
"@kbn/remote-clusters-plugin": "link:x-pack/platform/plugins/private/remote_clusters",

src/core/packages/saved-objects/api-server-internal/src/lib/apis/bulk_create.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ describe('#bulkCreate', () => {
10931093

10941094
describe('access control', () => {
10951095
const CURRENT_USER_PROFILE_ID = 'current_user_profile_id';
1096-
const READ_ONLY_TYPE = 'read-only-type';
1096+
const ACCESS_CONTROL_TYPE = 'access-control-type';
10971097

10981098
beforeEach(() => {
10991099
securityExtension.getCurrentUser.mockReturnValue({
@@ -1116,7 +1116,7 @@ describe('#bulkCreate', () => {
11161116
});
11171117

11181118
registry.registerType({
1119-
name: READ_ONLY_TYPE,
1119+
name: ACCESS_CONTROL_TYPE,
11201120
hidden: false,
11211121
namespaceType: 'multiple-isolated',
11221122
supportsAccessControl: true,
@@ -1143,13 +1143,13 @@ describe('#bulkCreate', () => {
11431143
references: [{ name: 'ref_0', type: 'test', id: '1' }],
11441144
};
11451145
const obj2AccessControl = {
1146-
type: READ_ONLY_TYPE,
1146+
type: ACCESS_CONTROL_TYPE,
11471147
id: 'has-read-only-metadata',
11481148
attributes: { title: 'Test Two' },
11491149
references: [{ name: 'ref_0', type: 'test', id: '2' }],
11501150
};
11511151
await bulkCreateSuccess(client, repository, [obj1NoAccessControl, obj2AccessControl], {
1152-
accessControl: { accessMode: 'read_only' },
1152+
accessControl: { accessMode: 'write_restricted' },
11531153
});
11541154

11551155
expect(securityExtension.authorizeBulkCreate).toHaveBeenCalledWith(
@@ -1164,14 +1164,14 @@ describe('#bulkCreate', () => {
11641164
// explicitly confirm there is no accessControl for non-supporting type
11651165
},
11661166
{
1167-
type: READ_ONLY_TYPE,
1167+
type: ACCESS_CONTROL_TYPE,
11681168
id: 'has-read-only-metadata',
11691169
name: 'Test Two',
11701170
existingNamespaces: [],
11711171
initialNamespace: undefined,
11721172
accessControl: {
11731173
owner: CURRENT_USER_PROFILE_ID,
1174-
accessMode: 'read_only',
1174+
accessMode: 'write_restricted',
11751175
},
11761176
},
11771177
]),
@@ -1186,11 +1186,11 @@ describe('#bulkCreate', () => {
11861186
attributes: { title: 'Test One' },
11871187
references: [{ name: 'ref_0', type: 'test', id: '1' }],
11881188
accessControl: {
1189-
accessMode: 'read_only',
1189+
accessMode: 'write_restricted',
11901190
} as Pick<SavedObjectAccessControl, 'accessMode'>,
11911191
};
11921192
const obj2AccessControl = {
1193-
type: READ_ONLY_TYPE,
1193+
type: ACCESS_CONTROL_TYPE,
11941194
id: 'has-read-only-metadata',
11951195
attributes: { title: 'Test Two' },
11961196
references: [{ name: 'ref_0', type: 'test', id: '2' }],
@@ -1199,7 +1199,7 @@ describe('#bulkCreate', () => {
11991199
} as Pick<SavedObjectAccessControl, 'accessMode'>,
12001200
};
12011201
const obj3AccessControl = {
1202-
type: READ_ONLY_TYPE,
1202+
type: ACCESS_CONTROL_TYPE,
12031203
id: 'has-read-only-metadata',
12041204
attributes: { title: 'Test Three' },
12051205
references: [{ name: 'ref_0', type: 'test', id: '3' }],
@@ -1209,7 +1209,7 @@ describe('#bulkCreate', () => {
12091209
repository,
12101210
[obj1NoAccessControl, obj2AccessControl, obj3AccessControl],
12111211
{
1212-
accessControl: { accessMode: 'read_only' },
1212+
accessControl: { accessMode: 'write_restricted' },
12131213
}
12141214
);
12151215

@@ -1225,7 +1225,7 @@ describe('#bulkCreate', () => {
12251225
// explicitly confirm there is no accessControl for non-supporting type
12261226
},
12271227
{
1228-
type: READ_ONLY_TYPE,
1228+
type: ACCESS_CONTROL_TYPE,
12291229
id: 'has-read-only-metadata',
12301230
name: 'Test Two',
12311231
existingNamespaces: [],
@@ -1236,14 +1236,14 @@ describe('#bulkCreate', () => {
12361236
},
12371237
},
12381238
{
1239-
type: READ_ONLY_TYPE,
1239+
type: ACCESS_CONTROL_TYPE,
12401240
id: 'has-read-only-metadata',
12411241
name: 'Test Three',
12421242
existingNamespaces: [],
12431243
initialNamespace: undefined,
12441244
accessControl: {
12451245
owner: CURRENT_USER_PROFILE_ID,
1246-
accessMode: 'read_only', // explicitly confirm the mode is NOT overriden
1246+
accessMode: 'write_restricted', // explicitly confirm the mode is NOT overriden
12471247
},
12481248
},
12491249
]),
@@ -1261,13 +1261,13 @@ describe('#bulkCreate', () => {
12611261
references: [{ name: 'ref_0', type: 'test', id: '1' }],
12621262
};
12631263
const obj2AccessControl = {
1264-
type: READ_ONLY_TYPE,
1264+
type: ACCESS_CONTROL_TYPE,
12651265
id: 'has-read-only-metadata',
12661266
attributes: { title: 'Test Two' },
12671267
references: [{ name: 'ref_0', type: 'test', id: '2' }],
12681268
};
12691269
await bulkCreateSuccess(client, repository, [obj1NoAccessControl, obj2AccessControl], {
1270-
accessControl: { accessMode: 'read_only' },
1270+
accessControl: { accessMode: 'write_restricted' },
12711271
});
12721272

12731273
expect(securityExtension.authorizeBulkCreate).toHaveBeenCalledWith(
@@ -1297,7 +1297,7 @@ describe('#bulkCreate', () => {
12971297
references: [{ name: 'ref_0', type: 'test', id: '1' }],
12981298
};
12991299
const obj2AccessControl = {
1300-
type: READ_ONLY_TYPE,
1300+
type: ACCESS_CONTROL_TYPE,
13011301
id: 'could-have-read-only-metadata',
13021302
attributes: { title: 'Test Two' },
13031303
references: [{ name: 'ref_0', type: 'test', id: '2' }],
@@ -1316,7 +1316,7 @@ describe('#bulkCreate', () => {
13161316
// explicitly confirm there is no accessControl for non-supporting type
13171317
},
13181318
{
1319-
type: READ_ONLY_TYPE,
1319+
type: ACCESS_CONTROL_TYPE,
13201320
id: 'could-have-read-only-metadata',
13211321
name: 'Test Two',
13221322
existingNamespaces: [],

src/core/packages/saved-objects/api-server-internal/src/lib/apis/create.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ describe('#create', () => {
862862
id,
863863
namespace,
864864
accessControl: {
865-
accessMode: 'read_only',
865+
accessMode: 'write_restricted',
866866
},
867867
})
868868
).rejects.toThrowError(
@@ -878,7 +878,7 @@ describe('#create', () => {
878878
mockAuthenticatedUser({ profile_uid: 'u_test_user_version' })
879879
);
880880
const accessControl = {
881-
accessMode: 'read_only' as const,
881+
accessMode: 'write_restricted' as const,
882882
};
883883

884884
const result = await repository.create(ACCESS_CONTROL_TYPE, attributes, {
@@ -901,7 +901,7 @@ describe('#create', () => {
901901
updated_by: 'u_test_user_version',
902902
created_by: 'u_test_user_version',
903903
accessControl: {
904-
accessMode: 'read_only',
904+
accessMode: 'write_restricted',
905905
owner: 'u_test_user_version',
906906
},
907907
});
@@ -915,12 +915,12 @@ describe('#create', () => {
915915
namespace,
916916
references,
917917
accessControl: {
918-
accessMode: 'read_only',
918+
accessMode: 'write_restricted',
919919
},
920920
})
921921
).rejects.toThrowError(
922922
createBadRequestErrorPayload(
923-
`Unable to create \"read_only\" \"accessControlType\" saved object. User profile ID not found.`
923+
`Unable to create \"write_restricted\" \"accessControlType\" saved object. User profile ID not found.`
924924
)
925925
);
926926
expect(client.create).not.toHaveBeenCalled();

src/core/packages/saved-objects/api-server-internal/src/lib/apis/create.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ export const performCreate = async <T>(
113113
);
114114
}
115115

116-
if (!createdBy && accessMode === 'read_only') {
116+
if (!createdBy && accessMode === 'write_restricted') {
117117
throw SavedObjectsErrorHelpers.createBadRequestError(
118-
`Unable to create "read_only" "${type}" saved object. User profile ID not found.`
118+
`Unable to create "write_restricted" "${type}" saved object. User profile ID not found.`
119119
);
120120
}
121121

0 commit comments

Comments
 (0)