[
https://issues.apache.org/jira/browse/METRON-1712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16573704#comment-16573704
]
ASF GitHub Bot commented on METRON-1712:
----------------------------------------
Github user tiborm commented on a diff in the pull request:
https://github.com/apache/metron/pull/1142#discussion_r208695454
--- Diff:
metron-interface/metron-alerts/src/app/pcap/pcap-filters/pcap-filters.component.spec.ts
---
@@ -331,13 +337,60 @@ describe('PcapFiltersComponent', () => {
validValues.forEach((value) => {
const els = getFieldWithSubmit('ip-dest-port');
+ expect(isFieldInvalid(els.field)).toBe(false, 'the field should be
valid without ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit
button should be enabled without ' + value);
+
+ setFieldValue(els.field, value);
+
expect(isFieldInvalid(els.field)).toBe(false, 'the field should be
valid with ' + value);
expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit
button should be enabled with ' + value);
+ tearDown(els.field);
+ });
+ });
+
+
+ it('should disable the form if the ip source field is invalid', () => {
+ const invalidValues = [
+ 'tst',
+ 0o0,
+ 0,
+ '111.111.111',
+ '222.222.222.222.222',
+ '333.333.333.333',
+ ];
+
+ invalidValues.forEach((value) => {
+ const els = getFieldWithSubmit('ip-src-addr');
+ expect(isFieldInvalid(els.field)).toBe(false, 'the field should be
valid without ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit
button should be enabled without ' + value);
+
setFieldValue(els.field, value);
- expect(isFieldInvalid(els.field)).toBe(false, 'the field should be
valid with ' + value);
+
+ expect(isFieldInvalid(els.field)).toBe(true, 'the field should be
invalid with ' + value);
+ expect(isSubmitDisabled(els.submit)).toBe(true, 'the submit button
should be disabled with ' + value);
+ tearDown(els.field);
+ });
+ });
+
+ it('should keep the form enabled if the ip source field is valid', ()
=> {
+ const invalidValues = [
--- End diff --
Fixed. Thanks!
> PCAP UI - Input validation
> --------------------------
>
> Key: METRON-1712
> URL: https://issues.apache.org/jira/browse/METRON-1712
> Project: Metron
> Issue Type: Sub-task
> Reporter: Shane Ardell
> Priority: Major
>
> The following fields need input validation:
> IP Source Address: should accept valid IPv4 address formats (v6 is not yet
> supported)
> IP Source Port: should accept integers from 0 to 65535
> IP Source Address: should accept valid IPv4 address formats (v6 is not yet
> supported)
> IP Dest Port: should accept integers from 0 to 65535
> Leave unvalidated:
> Protocol: number of valid protocols is around 150 and it could change in the
> future, validation possible makes more sense on the backend or by a separated
> endpoint
> Free text filtering: binary regular expression
> Broken inputs should be recognized by the UI and not submitted, with
> user-facing feedback. The REST API should also fail on queries outside
> reasonable parameters.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)