Make ip_address read only

Setting a different value for ip_address
and hostname does not work with the current
way we create receptor certs.
This commit is contained in:
Seth Foster
2023-08-17 15:41:04 -04:00
committed by Seth Foster
parent eba130cf41
commit 965127637b
5 changed files with 5 additions and 36 deletions

View File

@@ -166,15 +166,6 @@ class TestPeers:
expect=400,
)
def test_disallow_changing_ip_address(self, admin_user, patch):
hop = Instance.objects.create(hostname='hop', ip_address='10.10.10.10', node_type='hop')
patch(
url=reverse('api:instance_detail', kwargs={'pk': hop.pk}),
data={"ip_address": "12.12.12.12"},
user=admin_user,
expect=400,
)
def test_disallow_changing_node_state(self, admin_user, patch):
'''
only allow setting to deprovisioning
@@ -214,7 +205,7 @@ class TestPeers:
if a new node comes online, other peer relationships should
remain intact
'''
hop1 = Instance.objects.create(hostname='hop1', ip_address="10.10.10.10", node_type='hop', listener_port=6789, peers_from_control_nodes=True)
hop1 = Instance.objects.create(hostname='hop1', node_type='hop', listener_port=6789, peers_from_control_nodes=True)
hop2 = Instance.objects.create(hostname='hop2', node_type='hop', listener_port=6789, peers_from_control_nodes=False)
hop1.peers.add(hop2)
@@ -265,18 +256,6 @@ class TestPeers:
assert not has_peer(execution_vars, 'hop1:6789')
assert execution_vars.get('receptor_listener', False)
def test_group_vars_ip_address_over_hostname(self):
'''
test that ip_address has precedence over hostname in group_vars all.yml
'''
hop1 = Instance.objects.create(hostname='hop1', node_type='hop', listener_port=6789, peers_from_control_nodes=True)
hop2 = Instance.objects.create(hostname='hop2', ip_address="10.10.10.10", node_type='hop', listener_port=6789, peers_from_control_nodes=False)
hop1.peers.add(hop2)
hop1_vars = yaml.safe_load(generate_group_vars_all_yml(hop1))
assert has_peer(hop1_vars, "10.10.10.10:6789")
def test_write_receptor_config_called(self):
'''
Assert that write_receptor_config is called