-
Notifications
You must be signed in to change notification settings - Fork 52
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
Create IP randomization function for test suites #27
Comments
I was also thinking about supporting a whitelist or blacklist. e.g. pass it a list of blocks to exclude due to business logic restrictions etc. |
I like the thought of a whitelist/blacklist, sounds like it would be very useful. |
Another use case I have considered in the past is maintaining octet size. This comes into play when replacing IP addresses that change the whitespace of the output. As networking is still heavy parsing, this has bit me before.
turns into
|
For that use case, would it be better to address the issue in the template that generates test cases? template = """IP Name description
-------------------------------------------------------
{ip1} Hello description should start on char 25
{ip2} World description should start on char 25
"""
ip1 = "100.30.182.1"
ip2 = "1.1.1.2"
print(template.format(ip1=ip1, ip2=ip2))
template = """IP Name description
-------------------------------------------------------
{ip1:<14} Hello description should start on char 25
{ip2:<14} World description should start on char 25
"""
print(template.format(ip1=ip1, ip2=ip2)) IP Name description
-------------------------------------------------------
100.30.182.1 Hello description should start on char 25
1.1.1.2 World description should start on char 25
IP Name description
-------------------------------------------------------
100.30.182.1 Hello description should start on char 25
1.1.1.2 World description should start on char 25 Would this address your concern? |
The use case is anonymizing and generating the data. Imagine taking in dozens of outputs for an ntc-templates PR and you obviously cannot use your companies IPs, so you want to anonymize. If you anonymize without keeping the octet structure the same, you will end up with bad data. |
I've poked around with this quite a bit this week, and I hope to have a draft submitted tomorrow. I think randomization and obfuscation should be dealt with in different functions. I am happy to add the latter based on the work you shared from the ansible module. |
Environment
Proposed Functionality
This functionality is largely supported in Faker, but I am proposing a stand-alone utility with extra nerd knobs.
generate_random_ip(*args)
and/orgenerate_random_network(*args)
args:
returns:
ipaddress.ip_address
/ipaddress.ip_network
Use Case
Random IP/networks for unit testing
@itdependsnetworks @jeffkala
The text was updated successfully, but these errors were encountered: