-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Prevent cloud users from updating their user profile #132622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
azasypkin
merged 4 commits into
elastic:feature/user-profile
from
azasypkin:issue-129238-prevent-cloud-users
Jun 1, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d7009c2
Prevent cloud users from updating their user profile.
azasypkin c26c503
Review#1: add few server tests for cloud/plugin.ts.
azasypkin 3fc96aa
Merge branch 'feature/user-profile' into issue-129238-prevent-cloud-u…
azasypkin a53a3dc
Merge branch 'feature/user-profile' into issue-129238-prevent-cloud-u…
azasypkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { coreMock } from '@kbn/core/server/mocks'; | ||
| import { CloudPlugin } from './plugin'; | ||
| import { config } from './config'; | ||
| import { securityMock } from '@kbn/security-plugin/server/mocks'; | ||
| import { usageCollectionPluginMock } from '@kbn/usage-collection-plugin/server/mocks'; | ||
|
|
||
| describe('Cloud Plugin', () => { | ||
| describe('#setup', () => { | ||
| describe('setupSecurity', () => { | ||
| it('properly handles missing optional Security dependency if Cloud ID is NOT set.', async () => { | ||
| const plugin = new CloudPlugin( | ||
| coreMock.createPluginInitializerContext(config.schema.validate({})) | ||
| ); | ||
|
|
||
| expect(() => | ||
| plugin.setup(coreMock.createSetup(), { | ||
| usageCollection: usageCollectionPluginMock.createSetupContract(), | ||
| }) | ||
| ).not.toThrow(); | ||
| }); | ||
|
|
||
| it('properly handles missing optional Security dependency if Cloud ID is set.', async () => { | ||
| const plugin = new CloudPlugin( | ||
| coreMock.createPluginInitializerContext(config.schema.validate({ id: 'my-cloud' })) | ||
| ); | ||
|
|
||
| expect(() => | ||
| plugin.setup(coreMock.createSetup(), { | ||
| usageCollection: usageCollectionPluginMock.createSetupContract(), | ||
| }) | ||
| ).not.toThrow(); | ||
| }); | ||
|
|
||
| it('does not notify Security plugin about Cloud environment if Cloud ID is NOT set.', async () => { | ||
| const plugin = new CloudPlugin( | ||
| coreMock.createPluginInitializerContext(config.schema.validate({})) | ||
| ); | ||
|
|
||
| const securityDependencyMock = securityMock.createSetup(); | ||
| plugin.setup(coreMock.createSetup(), { | ||
| security: securityDependencyMock, | ||
| usageCollection: usageCollectionPluginMock.createSetupContract(), | ||
| }); | ||
|
|
||
| expect(securityDependencyMock.setIsElasticCloudDeployment).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('properly notifies Security plugin about Cloud environment if Cloud ID is set.', async () => { | ||
| const plugin = new CloudPlugin( | ||
| coreMock.createPluginInitializerContext(config.schema.validate({ id: 'my-cloud' })) | ||
| ); | ||
|
|
||
| const securityDependencyMock = securityMock.createSetup(); | ||
| plugin.setup(coreMock.createSetup(), { | ||
| security: securityDependencyMock, | ||
| usageCollection: usageCollectionPluginMock.createSetupContract(), | ||
| }); | ||
|
|
||
| expect(securityDependencyMock.setIsElasticCloudDeployment).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT/optional: Shame on us, we don't yet have a test file for
x-pack/plugins/cloud/server/plugin.ts, but it would make sense to add one to test this call/behaviorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, I'll add one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added few basic tests in c26c503