Skip to content
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

Implements input validation for the AplicationId #135

Merged
merged 3 commits into from
Apr 15, 2020

Conversation

andreban
Copy link
Member

@andreban andreban commented Apr 9, 2020

  • Implements validation and tests
  • Improves some error messages on the CLI

@andreban andreban requested a review from PEConn April 9, 2020 19:49
- Implements validation and tests
- Improves some error messages on the CLI
- Removes repetitions for notEmpty validations.
- Improves validation for keystore passwords.
- Adds tests for notEmpty, validateKeyPassword and validatecolor.
Copy link
Collaborator

@PEConn PEConn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me % a few comments.

it('returns false for packages with invalid characters', () => {
expect(util.validatePackageId('com.pwa-directory.appspot.com')).toBeFalse();
expect(util.validatePackageId('[email protected]')).toBeFalse();
expect(util.validatePackageId('com.pwa*directory.appspot.com')).toBeFalse();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth adding an example with some weird unicode character (maybe a unicode character that looks like a full stop but isn't).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

it('packages starting with non-letters return false', () => {
expect(util.validatePackageId('com.1char.twa')).toBeFalse();
expect(util.validatePackageId('1com.char.twa')).toBeFalse();
expect(util.validatePackageId('com.char.1twa')).toBeFalse();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One that starts with an underscore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\u2024 () should do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}, {
name: 'keyAlias',
type: 'input',
message: 'Key name:',
default: twaManifest.signingKey.alias,
validate: notEmpty,
validate: async (input): Promise<boolean> => notEmpty(input, 'Key alias cannot be empty'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you just pass the name to notEmpty and have notEmpty take care of the "cannot be empty" part? (As it is, for half of these you say "cannot be empty" and the other half you have "can't be empty".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

await expectAsync(inputHelpers.validateKeyPassword(' ')).toBeRejectedWithError();
});

it('throws Error for empty string', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description is wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

await expectAsync(inputHelpers.validateKeyPassword('abcde ')).toBeRejectedWithError();
});

it('throws Error for empty string', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@andreban andreban merged commit 652b20e into GoogleChromeLabs:master Apr 15, 2020
@andreban andreban added the enhancement New feature or request label Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants