Skip to content

Commit

Permalink
Change validation for patch manifests (#2586)
Browse files Browse the repository at this point in the history
  • Loading branch information
ammont82 authored May 28, 2024
1 parent 1ed5732 commit 10e299e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,22 @@ describe(`Assisted Installer Custom manifests step`, () => {
.attachFile(`custom-manifests/files/manifest_multiple.yaml`);
commonActions.verifyNextIsEnabled();
});

it('Testing that incorrect patch name for manifests is not allowed', () => {
CustomManifestsForm.initManifest(0);
CustomManifestsForm.expandedManifest(0).fileName().clear().type('test.yaml.patch.aaa');
CustomManifestsForm.expandedManifest(0)
.fileNameError()
.should(
'contain.text',
'Must have a yaml, yml, json, yaml.patch or yml.patch extension and can not contain /.',
);

CustomManifestsForm.validationAlert().should(
'contain.text',
'Custom manifests configuration contains missing or invalid fields',
);
commonActions.verifyNextIsDisabled();
});
});
});
2 changes: 1 addition & 1 deletion libs/ui-lib/lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import isString from 'lodash-es/isString.js';
import { loadAll } from 'js-yaml';
import { MAX_FILE_SIZE_BYTES, MAX_FILE_SIZE_OFFSET_FACTOR } from './configurations';

export const FILENAME_REGEX = /^[^/]*\.(yaml|yml|json|yaml.patch.*|yml.patch.*)$/;
export const FILENAME_REGEX = /^[^\/]*\.(json|ya?ml(\.patch_?[a-zA-Z0-9_]*)?)$/;

export const FILE_TYPE_MESSAGE = 'Unsupported file type. Please provide a valid YAML file.';
export const INCORRECT_TYPE_FILE_MESSAGE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ export const CustomManifestsForm = ({

const handleSubmit: FormikConfig<ManifestFormData>['onSubmit'] = React.useCallback(
async ({ manifests }, actions) => {
clearAlerts();
if (manifests.length < customManifestsLocalRef.current.length) {
// submit was triggered by deleting a manifest

customManifestsLocalRef.current = manifests;
return;
} else {
clearAlerts();
actions.setSubmitting(true);

for (let index = 0; index < manifests.length; index++) {
Expand Down

0 comments on commit 10e299e

Please sign in to comment.