-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
23 changed files
with
229 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
2 changes: 1 addition & 1 deletion
2
src/core/server/elasticsearch/__snapshots__/elasticsearch_config.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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 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 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 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
53 changes: 53 additions & 0 deletions
53
x-pack/plugins/security/public/management/users/user_utils.test.ts
This file contains 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,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { User } from '../../../common/model'; | ||
import { isUserReserved, isUserDeprecated, getExtendedUserDeprecationNotice } from './user_utils'; | ||
|
||
describe('#isUserReserved', () => { | ||
it('returns false for a user with no metadata', () => { | ||
expect(isUserReserved({} as User)).toEqual(false); | ||
}); | ||
|
||
it('returns false for a user with the reserved flag set to false', () => { | ||
expect(isUserReserved({ metadata: { _reserved: false } } as User)).toEqual(false); | ||
}); | ||
|
||
it('returns true for a user with the reserved flag set to true', () => { | ||
expect(isUserReserved({ metadata: { _reserved: true } } as User)).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('#isUserDeprecated', () => { | ||
it('returns false for a user with no metadata', () => { | ||
expect(isUserDeprecated({} as User)).toEqual(false); | ||
}); | ||
|
||
it('returns false for a user with the deprecated flag set to false', () => { | ||
expect(isUserDeprecated({ metadata: { _deprecated: false } } as User)).toEqual(false); | ||
}); | ||
|
||
it('returns true for a user with the deprecated flag set to true', () => { | ||
expect(isUserDeprecated({ metadata: { _deprecated: true } } as User)).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('#getExtendedUserDeprecationNotice', () => { | ||
it('returns a notice when no reason is provided', () => { | ||
expect( | ||
getExtendedUserDeprecationNotice({ username: 'test_user' } as User) | ||
).toMatchInlineSnapshot(`"The test_user user is deprecated. "`); | ||
}); | ||
|
||
it('returns a notice augmented with reason when provided', () => { | ||
expect( | ||
getExtendedUserDeprecationNotice({ | ||
username: 'test_user', | ||
metadata: { _reserved: true, _deprecated_reason: 'some reason' }, | ||
} as User) | ||
).toMatchInlineSnapshot(`"The test_user user is deprecated. some reason"`); | ||
}); | ||
}); |
Oops, something went wrong.