Skip to content

Sync cross-field validation in IP form#4493

Open
zaelgohary wants to merge 2 commits intodevelopmentfrom
development_sync_range_ip
Open

Sync cross-field validation in IP form#4493
zaelgohary wants to merge 2 commits intodevelopmentfrom
development_sync_range_ip

Conversation

@zaelgohary
Copy link
Copy Markdown
Contributor

Sync cross-field validation, return early on any invalid IP, wrap getIPRange in try-catch to handle any remaining errors gracefully, and add unit tests

#4492

…IPRange in try-catch to handle any remaining errors gracefully, add unit tests
Copy link
Copy Markdown
Contributor

@AhmedHanafy725 AhmedHanafy725 left a comment

Choose a reason for hiding this comment

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

Please add how to run these tests

}));

describe("Add IP Range Validation", () => {
// Replicate the validateIPRange function logic for testing
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Replicating the code wouldn't find any issues if the methods used to validate the IPs changed.

vi.mocked(CidrTools.containsCidr).mockImplementation(() => {
throw new Error("Invalid CIDR");
});
const result = gatewayCheck("192.168.1.254", "192.168.1.1/24", undefined, IPType.single);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

192.168.1.254 is in range of 192.168.1.1/24, why it should fail?

@zaelgohary
Copy link
Copy Markdown
Contributor Author

Please add how to run these tests

From playground path, run npm run test:unit -- tests/components/add_ip.test.ts --run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants