mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
Stop SMTP password from incorrectly preventing App Settings PATCH requests (#1076)
* Stop validating fake password
This commit is contained in:
parent
8432d0494f
commit
949b9b53b1
3
frontend/app_constants/APP_SETTINGS.js
Normal file
3
frontend/app_constants/APP_SETTINGS.js
Normal file
@ -0,0 +1,3 @@
|
||||
export default {
|
||||
FAKE_PASSWORD: '********',
|
||||
};
|
7
frontend/app_constants/index.js
Normal file
7
frontend/app_constants/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
import APP_SETTINGS from 'app_constants/APP_SETTINGS';
|
||||
import PATHS from 'router/paths';
|
||||
|
||||
export default {
|
||||
APP_SETTINGS,
|
||||
PATHS,
|
||||
};
|
@ -1,5 +1,9 @@
|
||||
import { size, some } from 'lodash';
|
||||
|
||||
import APP_CONSTANTS from 'app_constants';
|
||||
|
||||
const { APP_SETTINGS } = APP_CONSTANTS;
|
||||
|
||||
export default (formData) => {
|
||||
const errors = {};
|
||||
const {
|
||||
@ -21,7 +25,7 @@ export default (formData) => {
|
||||
errors.org_name = 'Organization Name must be present';
|
||||
}
|
||||
|
||||
if (some([smtpSenderAddress, smtpPassword, smtpServer, smtpUserName])) {
|
||||
if (some([smtpSenderAddress, smtpServer, smtpUserName]) || (smtpPassword && smtpPassword !== APP_SETTINGS.FAKE_PASSWORD)) {
|
||||
if (!smtpSenderAddress) {
|
||||
errors.sender_address = 'SMTP Sender Address must be present';
|
||||
}
|
||||
|
@ -117,6 +117,37 @@ describe('AppConfigForm - validations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('does not validate smtp config if only password is present and it is the fake password', () => {
|
||||
const formData = {
|
||||
...validFormData,
|
||||
user_name: '',
|
||||
server: '',
|
||||
sender_address: '',
|
||||
password: '********',
|
||||
};
|
||||
const invalidFormData = {
|
||||
...validFormData,
|
||||
user_name: '',
|
||||
server: '',
|
||||
sender_address: '',
|
||||
password: 'newPassword',
|
||||
};
|
||||
|
||||
expect(validate(formData)).toEqual({
|
||||
valid: true,
|
||||
errors: {},
|
||||
});
|
||||
|
||||
expect(validate(invalidFormData)).toEqual({
|
||||
valid: false,
|
||||
errors: {
|
||||
sender_address: 'SMTP Sender Address must be present',
|
||||
server: 'SMTP Server must be present',
|
||||
user_name: 'SMTP Username must be present',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('does not validate the user_name and password if the auth type is "none"', () => {
|
||||
const formData = {
|
||||
...validFormData,
|
||||
|
Loading…
Reference in New Issue
Block a user