From 5539f36bd94781696de36b85a0f571b4d32b46b4 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Fri, 16 May 2025 10:33:01 +0200 Subject: [PATCH 1/2] Fix error --- IM/connectors/EGI.py | 2 ++ test/unit/connectors/EGI.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/IM/connectors/EGI.py b/IM/connectors/EGI.py index 001d81340..dad707201 100644 --- a/IM/connectors/EGI.py +++ b/IM/connectors/EGI.py @@ -78,6 +78,7 @@ def add_dns_entry(self, hostname, domain, ip, auth_data, extra_args=None): """ Add a DNS entry to the DNS server """ + domain = domain[:-1] if domain.endswith(".") else domain im_auth = auth_data.getAuthInfo("InfrastructureManager") try: secret = None @@ -144,6 +145,7 @@ def del_dns_entry(self, hostname, domain, ip, auth_data, extra_args=None): """ Delete a DNS entry from the DNS server """ + domain = domain[:-1] if domain.endswith(".") else domain im_auth = auth_data.getAuthInfo("InfrastructureManager") try: if im_auth and im_auth[0].get("token"): diff --git a/test/unit/connectors/EGI.py b/test/unit/connectors/EGI.py index 77929fb5f..549d1915b 100755 --- a/test/unit/connectors/EGI.py +++ b/test/unit/connectors/EGI.py @@ -70,7 +70,7 @@ def test_del_dns(self, mock_get_domains, mock_get_host, mock_get): mock_get.return_value = MagicMock(status_code=200, json=lambda: {"status": "ok"}) auth_data = Authentication([{'type': 'InfrastructureManager', 'token': 'access_token'}]) cloud = EGICloudConnector(None, None) - success = EGICloudConnector.del_dns_entry(cloud, "hostname", "domain", "ip", auth_data) + success = EGICloudConnector.del_dns_entry(cloud, "hostname", "domain.", "ip", auth_data) self.assertTrue(success) eurl = f"{EGICloudConnector.DYDNS_URL}/nic/unregister?fqdn=hostname.domain" mock_get.assert_called_with(eurl, headers={'Authorization': 'Bearer access_token'}, timeout=10) From e27ec3143cb44cbc53b78ce5ccc317ebe45c1916 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Fri, 16 May 2025 10:49:30 +0200 Subject: [PATCH 2/2] Fix error --- IM/connectors/EGI.py | 1 - 1 file changed, 1 deletion(-) diff --git a/IM/connectors/EGI.py b/IM/connectors/EGI.py index dad707201..9555754d7 100644 --- a/IM/connectors/EGI.py +++ b/IM/connectors/EGI.py @@ -117,7 +117,6 @@ def add_dns_entry(self, hostname, domain, ip, auth_data, extra_args=None): parts = hostname[6:].split("@") secret = parts[0] hostname = parts[1] - domain = domain[:-1] else: self.log_error(f"Error updating DNS entry {hostname}.{domain}: No secret nor token provided") return False