Skip to content

Commit

Permalink
Refactor test data generation and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonKohli committed Feb 1, 2024
1 parent 56df89b commit 68d2b98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 351 deletions.
366 changes: 15 additions & 351 deletions ip-atlas/testdatenfiller.py
Original file line number Diff line number Diff line change
@@ -1,353 +1,17 @@
from helper import *
from helper import writeJson
from faker import Faker

fake = Faker()

writeJson(
"Host1",
"192.168.0.1",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
[80, 443],
)
writeJson(
"Host2",
"192.168.0.2",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7335",
[22, 8080],
)
writeJson(
"Host3",
"192.168.0.3",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7336",
[8080, 9090],
)
writeJson(
"Host4",
"192.168.0.4",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7337",
[443, 8081],
)
writeJson(
"Host5",
"192.168.0.5",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7338",
[22, 80],
)
writeJson(
"Host6",
"192.168.0.6",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7339",
[8080, 8443],
)
writeJson(
"Host7",
"192.168.0.7",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7340",
[21, 587],
)
writeJson(
"Host8",
"192.168.0.8",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7341",
[8080, 9091],
)
writeJson(
"Host9",
"192.168.0.9",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7342",
[80, 443],
)
writeJson(
"Host10",
"192.168.0.10",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7343",
[22, 8080],
)
writeJson(
"Host11",
"192.168.0.11",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7344",
[8081, 9090],
)
writeJson(
"Host12",
"192.168.0.12",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7345",
[80, 8443],
)
writeJson(
"Host13",
"192.168.0.13",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7346",
[21, 587],
)
writeJson(
"Host14",
"192.168.0.14",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7347",
[8080, 9091],
)
writeJson(
"Host15",
"192.168.0.15",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7348",
[80, 443],
)
writeJson(
"Host16",
"192.168.0.16",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7349",
[22, 8080],
)
writeJson(
"Host17",
"192.168.0.17",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7350",
[8080, 9090],
)
writeJson(
"Host18",
"192.168.0.18",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7351",
[443, 8081],
)
writeJson(
"Host19",
"192.168.0.19",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7352",
[22, 80],
)
writeJson(
"Host20",
"192.168.0.20",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7353",
[8080, 8443],
)
writeJson(
"Host21",
"192.168.0.21",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7354",
[21, 587],
)
writeJson(
"Host22",
"192.168.0.22",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7355",
[8080, 9091],
)
writeJson(
"Host23",
"192.168.0.23",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7356",
[80, 443],
)
writeJson(
"Host24",
"192.168.0.24",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7357",
[22, 8080],
)
writeJson(
"Host25",
"192.168.0.25",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7358",
[8081, 9090],
)
writeJson(
"Host26",
"192.168.0.26",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7359",
[80, 8443],
)
writeJson(
"Host27",
"192.168.0.27",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7360",
[21, 587],
)
writeJson(
"Host28",
"192.168.0.28",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7361",
[8080, 9091],
)
writeJson(
"Host29",
"192.168.0.29",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7362",
[80, 443],
)
writeJson(
"Host30",
"192.168.0.30",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7363",
[22, 8080],
)
writeJson(
"Host31",
"192.168.0.31",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7364",
[8080, 9090],
)
writeJson(
"Host32",
"192.168.0.32",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7365",
[443, 8081],
)
writeJson(
"Host33",
"192.168.0.33",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7366",
[22, 80],
)
writeJson(
"Host34",
"192.168.0.34",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7367",
[8080, 8443],
)
writeJson(
"Host35",
"192.168.0.35",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7368",
[21, 587],
)
writeJson(
"Host36",
"192.168.0.36",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7369",
[8080, 9091],
)
writeJson(
"Host37",
"192.168.0.37",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7370",
[80, 443],
)
writeJson(
"Host38",
"192.168.0.38",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7371",
[22, 8080],
)
writeJson(
"Host39",
"192.168.0.39",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7372",
[8081, 9090],
)
writeJson(
"Host40",
"192.168.0.40",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7373",
[80, 8443],
)
writeJson(
"Host41",
"192.168.0.41",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7374",
[21, 587],
)
writeJson(
"Host42",
"192.168.0.42",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7375",
[8080, 9091],
)
writeJson(
"Host43",
"192.168.0.43",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7376",
[80, 443],
)
writeJson(
"Host44",
"192.168.0.44",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7377",
[22, 8080],
)
writeJson(
"Host45",
"192.168.0.45",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7378",
[8080, 9090],
)
writeJson(
"Host46",
"192.168.0.46",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7379",
[443, 8081],
)
writeJson(
"Host47",
"192.168.0.47",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7380",
[22, 80],
)
writeJson(
"Host48",
"192.168.0.48",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7381",
[8080, 8443],
)
writeJson(
"Host49",
"192.168.0.49",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7382",
[21, 587],
)
writeJson(
"Host50",
"192.168.0.50",
["Tag 1", "Tag 2", "test"],
"2001:0db8:85a3:0000:0000:8a2e:0370:7383",
[8080, 9091],
)

def generate_test_data(num_hosts=50):
for i in range(1, num_hosts + 1):
hostname = f"Host{i}"
ipv4 = fake.ipv4_private(network=False, address_class=None)
tags = [fake.word(), fake.word(), "test"]
ipv6 = fake.ipv6(network=False)
ports = [fake.random_int(min=1, max=65535) for _ in range(2)]
writeJson(hostname, ipv4, tags, ipv6, ports)


generate_test_data()
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
blinker==1.7.0
click==8.1.7
Faker==22.6.0
Flask==3.0.1
itsdangerous==2.1.2
Jinja2==3.1.3
MarkupSafe==2.1.4
python-dateutil==2.8.2
six==1.16.0
Werkzeug==3.0.1

0 comments on commit 68d2b98

Please sign in to comment.