-
Notifications
You must be signed in to change notification settings - Fork 162
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
Implements input validation for the AplicationId #135
Conversation
andreban
commented
Apr 9, 2020
- Implements validation and tests
- Improves some error messages on the CLI
- Implements validation and tests - Improves some error messages on the CLI
9862f8b
to
a40acc2
Compare
- Removes repetitions for notEmpty validations. - Improves validation for keystore passwords. - Adds tests for notEmpty, validateKeyPassword and validatecolor.
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 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(); |
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.
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).
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.
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(); |
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.
One that starts with an underscore?
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.
\u2024
(․
) should do it.
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.
done
packages/cli/src/lib/cmds/init.ts
Outdated
}, { | ||
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'), |
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.
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".
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.
done
await expectAsync(inputHelpers.validateKeyPassword(' ')).toBeRejectedWithError(); | ||
}); | ||
|
||
it('throws Error for empty string', async () => { |
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.
description is wrong.
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.
done
await expectAsync(inputHelpers.validateKeyPassword('abcde ')).toBeRejectedWithError(); | ||
}); | ||
|
||
it('throws Error for empty string', async () => { |
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.
here as well
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.
done