Stop SMTP password from incorrectly preventing App Settings PATCH requests (#1076)

* Stop validating fake password
This commit is contained in:
Mike Stone 2017-01-24 17:19:43 -05:00 committed by GitHub
parent 8432d0494f
commit 949b9b53b1
4 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,3 @@
export default {
FAKE_PASSWORD: '********',
};

View File

@ -0,0 +1,7 @@
import APP_SETTINGS from 'app_constants/APP_SETTINGS';
import PATHS from 'router/paths';
export default {
APP_SETTINGS,
PATHS,
};

View File

@ -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';
}

View File

@ -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,