Fix random_ipv6_cidr network generation, with test (#4438)
This commit is contained in:
parent
cc5a5c3d72
commit
0b647fdb8b
@ -252,7 +252,7 @@ def randor_ipv4_cidr():
|
||||
|
||||
|
||||
def random_ipv6_cidr():
|
||||
return "2400:6500:{}:{}::/56".format(random_resource_id(4), random_resource_id(4))
|
||||
return "2400:6500:{}:{}00::/56".format(random_resource_id(4), random_resource_id(2))
|
||||
|
||||
|
||||
def generate_route_id(
|
||||
|
@ -1,3 +1,6 @@
|
||||
import ipaddress
|
||||
from unittest.mock import patch
|
||||
|
||||
from moto.ec2 import utils
|
||||
|
||||
from .helpers import rsa_check_private_key
|
||||
@ -10,3 +13,13 @@ def test_random_key_pair():
|
||||
# AWS uses MD5 fingerprints, which are 47 characters long, *not* SHA1
|
||||
# fingerprints with 59 characters.
|
||||
assert len(key_pair["fingerprint"]) == 47
|
||||
|
||||
|
||||
def test_random_ipv6_cidr():
|
||||
def mocked_random_resource_id(chars: int):
|
||||
return "a" * chars
|
||||
|
||||
with patch("moto.ec2.utils.random_resource_id", mocked_random_resource_id):
|
||||
cidr_address = utils.random_ipv6_cidr()
|
||||
# this will throw value error if host bits are set
|
||||
ipaddress.ip_network(cidr_address)
|
||||
|
Loading…
Reference in New Issue
Block a user