-
Notifications
You must be signed in to change notification settings - Fork 172
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
Use password message from /dashboardsinfo #1503
Conversation
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
@@ -43,7 +62,7 @@ export function PasswordEditPanel(props: { | |||
|
|||
return ( | |||
<> | |||
<FormRow headerText="Password" helpText={PASSWORD_INSTRUCTION}> | |||
<FormRow data-test-subj="password-form-row" headerText="Password" helpText={passwordHelpText}> |
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.
qq. Why add data-test-subj
?
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.
I removed that, I was trying to write a test to verify the text after a state update in the password-edit-panel but opted instead to assert that setState with the custom message had been called.
|
||
beforeEach(() => { | ||
useEffect.mockImplementationOnce((f) => f()); | ||
useState.mockImplementation((initialValue) => [initialValue, setState]); | ||
(getDashboardsInfo as jest.Mock).mockImplementation(() => { |
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.
Is this still need even though it is mocked above?
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.
It is not, I removed this and also removed creating the shallow component in beforeEach and moved it into each individual test. The first test needs mount(...)
instead of shallow(...)
to test the logic in React.useEffect(...)
it('renders', (done) => { | ||
(getDashboardsInfo as jest.Mock).mockImplementation(() => { | ||
return mockDashboardsInfo; | ||
}); |
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.
Is this mock needed?
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.
Looks like this was made redundant by the block above:
jest.mock('../../../../utils/dashboards-info-utils', () => ({
getDashboardsInfo: jest.fn().mockImplementation(() => {
return mockDashboardsInfo;
}),
}));
I removed this redundant mock. Thanks for pointing that out.
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Codecov Report
@@ Coverage Diff @@
## main #1503 +/- ##
==========================================
- Coverage 66.11% 66.06% -0.06%
==========================================
Files 93 93
Lines 2314 2328 +14
Branches 310 310
==========================================
+ Hits 1530 1538 +8
- Misses 716 722 +6
Partials 68 68
|
Signed-off-by: Craig Perkins <cwperx@amazon.com>
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.
Hi @cwperks, thank you for this work and it looks good to me in general.
@@ -32,6 +32,7 @@ import { logout, updateNewPassword } from './utils'; | |||
import { PASSWORD_INSTRUCTION } from '../apps-constants'; |
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.
For this PASSWORD_INSTRUCTION
, should we also update it so that it has the new password rules that introduced by the strong password validation feature?
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.
Just like this password_validation_error_message
:
'Password must be minimum 5 characters long and must contain at least one uppercase letter, one lowercase letter, one digit, and one special character.'
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.
That's a good point and needs to be updated on the backend as well. I'll adjust it according to the description on the PR that introduced password strength: opensearch-project/security#2557
plugins.security.restapi.password_min_length - minimum password length, default and minimum is 8
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.
This is already properly set: https://github.com/opensearch-project/security-dashboards-plugin/blob/main/public/apps/apps-constants.tsx
Note: This default is duplicated and the frontend and backend. I decided to keep the value in the frontend, but it could certainly be removed from the frontend codebase in favor of just keeping a single reference on the backend.
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.
Let's do this as a follow up PR to unblock your change.
* Use password message from /dashboardsinfo Signed-off-by: Craig Perkins <cwperx@amazon.com> * Run eslint --fix Signed-off-by: Craig Perkins <cwperx@amazon.com> * Remove unused attribute Signed-off-by: Craig Perkins <cwperx@amazon.com> * Clean up test Signed-off-by: Craig Perkins <cwperx@amazon.com> * Remove redundant mock Signed-off-by: Craig Perkins <cwperx@amazon.com> * Removed TODO messages Signed-off-by: Craig Perkins <cwperx@amazon.com> --------- Signed-off-by: Craig Perkins <cwperx@amazon.com> (cherry picked from commit f774ae4)
* Use password message from /dashboardsinfo Signed-off-by: Craig Perkins <cwperx@amazon.com> * Run eslint --fix Signed-off-by: Craig Perkins <cwperx@amazon.com> * Remove unused attribute Signed-off-by: Craig Perkins <cwperx@amazon.com> * Clean up test Signed-off-by: Craig Perkins <cwperx@amazon.com> * Remove redundant mock Signed-off-by: Craig Perkins <cwperx@amazon.com> * Removed TODO messages Signed-off-by: Craig Perkins <cwperx@amazon.com> --------- Signed-off-by: Craig Perkins <cwperx@amazon.com> (cherry picked from commit f774ae4) Co-authored-by: Craig Perkins <cwperx@amazon.com>
* Use password message from /dashboardsinfo Signed-off-by: Craig Perkins <cwperx@amazon.com> * Run eslint --fix Signed-off-by: Craig Perkins <cwperx@amazon.com> * Remove unused attribute Signed-off-by: Craig Perkins <cwperx@amazon.com> * Clean up test Signed-off-by: Craig Perkins <cwperx@amazon.com> * Remove redundant mock Signed-off-by: Craig Perkins <cwperx@amazon.com> * Removed TODO messages Signed-off-by: Craig Perkins <cwperx@amazon.com> --------- Signed-off-by: Craig Perkins <cwperx@amazon.com> Signed-off-by: Sam <samuel.costa@eliatra.com>
This went in the 2.9 release not 2.10 so removing the label. |
Description
Companion Security PR: opensearch-project/security#2949
This PR uses the message from
/_plugins/_security/dashboardsinfo
to get the password message from the backend if its configured inopensearch.yml
. If the setting is not set, the backend will return the default.Category
[Enhancement, New feature, Bug fix, Test fix, Refactoring, Maintenance, Documentation]
Bug fix
Issues Resolved
#1501
Testing
Jest tests and manual dashboard testing of both password reset and password edit
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.