Esempio n. 1
0
    def test_027_cv_allowlist_delete(self):
        """Test CV's DELETE /allowlists/{name} Interface"""
        cv_client = RequestsClient(tenant_templ.verifier_base_url, tls_enabled)
        response = cv_client.delete(
            f"/v{self.api_version}/allowlists/test-allowlist", cert=tenant_templ.cert, verify=False
        )

        self.assertEqual(response.status_code, 204, "Non-successful CV allowlist Delete return code!")
Esempio n. 2
0
def doRegistrarDelete(registrar_ip, registrar_port, agent_id):
    client = RequestsClient(f'{registrar_ip}:{registrar_port}', tls_enabled)
    response = client.delete(f'/v{api_version}/agents/{agent_id}', cert=tls_cert_info, verify=False)
    response_body = response.json()

    if response.status_code == 200:
        logger.debug("Registrar deleted.")
    else:
        logger.warning("Status command response: %s Unexpected response from registrar.", response.status_code)
        keylime_logging.log_http_response(logger, logging.WARNING, response_body)
Esempio n. 3
0
    def test_050_cv_agent_delete(self):
        """Test CV's DELETE /agents/{UUID} Interface"""
        time.sleep(5)
        test_050_cv_agent_delete = RequestsClient(tenant_templ.verifier_base_url, tls_enabled)
        response = test_050_cv_agent_delete.delete(
            f"/v{self.api_version}/agents/{tenant_templ.agent_uuid}", cert=tenant_templ.cert, verify=False
        )

        self.assertEqual(response.status_code, 202, "Non-successful CV agent Delete return code!")
        json_response = response.json()

        # Ensure response is well-formed
        self.assertIn("results", json_response, "Malformed response body!")
Esempio n. 4
0
    def test_015_reg_agent_delete(self):

        """Test registrar's DELETE /agents/{UUID} Interface"""
        test_015_reg_agent_delete = RequestsClient(tenant_templ.registrar_base_tls_url, tls_enabled=True)
        response = test_015_reg_agent_delete.delete(
            f"/v{self.api_version}/agents/{tenant_templ.agent_uuid}", cert=tenant_templ.cert, verify=False
        )

        self.assertEqual(response.status_code, 200, "Non-successful Registrar Delete return code!")
        json_response = response.json()

        # Ensure response is well-formed
        self.assertIn("results", json_response, "Malformed response body!")
Esempio n. 5
0
    def do_cvdelete(self):
        """Delete agent from Verifier
        """
        do_cvdelete = RequestsClient(self.verifier_base_url, self.tls_enabled)
        response = do_cvdelete.delete(
            (f'/agents/{self.agent_uuid}'),
            cert=self.cert,
            verify=False
        )

        if response.status_code == 503:
            logger.error(
                f"Cannot connect to Verifier at {self.verifier_ip} with Port {self.verifier_port}. Connection refused.")
            sys.exit()
        elif response.status_code == 504:
            logger.error(
                f"Verifier at {self.verifier_ip} with Port {self.verifier_port} timed out.")
            sys.exit()

        if response.status_code == 202:
            deleted = False
            for _ in range(12):
                get_cvdelete = RequestsClient(
                    self.verifier_base_url, self.tls_enabled)
                response = get_cvdelete.get(
                    (f'/agents/{self.agent_uuid}'),
                    cert=self.cert,
                    verify=False
                )

                if response.status_code in (200, 404):
                    deleted = True
                    break
                time.sleep(.4)
            if deleted:
                logger.info(
                    f"CV completed deletion of agent {self.agent_uuid}")
            else:
                logger.error(
                    f"Timed out waiting for delete of agent {self.agent_uuid} to complete at CV")
                sys.exit()
        elif response.status_code == 200:
            logger.info(f"Agent {self.agent_uuid} deleted from the CV")
        else:
            response_body = response.json()
            keylime_logging.log_http_response(
                logger, logging.ERROR, response_body)
Esempio n. 6
0
 def do_delete_allowlist(self, name):
     cv_client = RequestsClient(self.verifier_base_url, self.tls_enabled)
     response = cv_client.delete(f'/allowlists/{name}',
                                 cert=self.cert, verify=False)
     print(response.json())