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

feat(anta.tests): Added testcase to verify domain name to IP address translation #534

Merged
merged 4 commits into from
Feb 23, 2024

Conversation

MaheshGSLAB
Copy link
Contributor

Description

Added testcase to verify domain name to IP address translation.

Fixes #533

  • success: The test will pass if a domain name is resolved to an IP address.
  • failure: The test will fail if a domain name does not resolve to an IP address.
  • error: This test will error out if a domain name is not correct.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have run pre-commit for code linting and typing (pre-commit run)
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (tox -e testenv)

@MaheshGSLAB MaheshGSLAB marked this pull request as ready for review January 22, 2024 10:04
Copy link
Contributor

@carl-baillargeon carl-baillargeon left a comment

Choose a reason for hiding this comment

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

Thanks Mahesh. Since services.py is a new module, you need to create the documentation: anta/docs/api/tests.services.md and add the section in anta/docs/api/tests.md.

Finally add your newly created MD file to mkdocs.yml. Double check the doc with mkdocs serve.

Thanks


class VerifyDNSLookup(AntaTest):
"""
This class verifies the DNS(Domain name service) name to IP address translation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This class verifies the DNS(Domain name service) name to IP address translation.
This class verifies the DNS (Domain name service) name to IP address translation.

domain = command.params["domain"]
output = command.json_output["messages"][0]
if f"Can't find {domain}: No answer" in output:
self.result.is_failure(f"Domain {domain} is not resolved to an IP address.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add the failed domains in a list or set and have a single failure message like: The following domain(s) are not resolved to an IP address: google.ca, arista.com

"""

name = "VerifyDNSLookup"
description = "Verifies the DNS(Domain name service) name to IP address translation."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description = "Verifies the DNS(Domain name service) name to IP address translation."
description = "Verifies the DNS (Domain name service) name to IP address translation."

# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
"""
Tests for anta.tests.security.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Tests for anta.tests.security.py
Tests for anta.tests.services.py

Copy link
Contributor

github-actions bot commented Feb 7, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

anta/tests/services.py Outdated Show resolved Hide resolved
anta/tests/services.py Show resolved Hide resolved
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link
Contributor

@carl-baillargeon carl-baillargeon left a comment

Choose a reason for hiding this comment

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

LGTM

@carl-baillargeon carl-baillargeon merged commit efdd997 into aristanetworks:main Feb 23, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the testcase to verify domain loop up(name to ip address translation)
2 participants