From d72a20dec0f787506eb1d60f2485b828fb59b94c Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Fri, 14 Jan 2022 09:54:51 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d665e2f..c77d83f 100644 --- a/README.md +++ b/README.md @@ -339,8 +339,10 @@ im_client.py [-u|--xmlrpc-url ] [-r|--restapi-url ] [-v|--verify-ssl] It has an optional parameter ``maxTime`` with the max time to wait. It returns 0 if the infrastructure ends with a "configured" state or 1 otherwise. - ``create_wait_outputs `` - This operation is a combination of the create, wait and getoutputs functions. First create the infrastructure, - then waits for it to be configured, and finally get the TOSCA outputs. In case of failure in infrastructure - creation none will be returned. In case of error waiting or getting the outputs only the infrastructure ID - will be returned. + ``create_wait_outputs inputfile`` + This operation is a combination of the create, wait and getoutputs functions. First it creates the + infrastructure using the specified ``inputfile``, then waits for it to be configured, and finally + gets the TOSCA outputs. In case of failure in then infrastructure creation step only the error message + will be returned. The results will be returned to stdout in json format:: + + {"infid": "ID", "error": "Error message"} From b13756bb66c7c16ead2febd6ee6751a6a744e73c Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 2 Feb 2022 13:42:41 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c77d83f..8004546 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![PyPI](https://img.shields.io/pypi/v/im-client.svg)](https://pypi.org/project/im-client) [![Build Status](http://jenkins.i3m.upv.es/buildStatus/icon?job=grycap/im-client-unit-py3)](http://jenkins.i3m.upv.es:8080/job/grycap/job/im-client-unit-py3/) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c74628a2fc134c2683d3fc57b571ce09)](https://www.codacy.com/app/micafer/im-client?utm_source=github.com&utm_medium=referral&utm_content=grycap/im-client&utm_campaign=Badge_Grade) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c74628a2fc134c2683d3fc57b571ce09)](https://www.codacy.com/gh/grycap/im-client/dashboard?utm_source=github.com&utm_medium=referral&utm_content=grycap/im-client&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/c74628a2fc134c2683d3fc57b571ce09)](https://www.codacy.com/app/micafer/im-client?utm_source=github.com&utm_medium=referral&utm_content=grycap/im-client&utm_campaign=Badge_Coverage) [![License](https://img.shields.io/badge/license-GPL%20v3.0-brightgreen.svg)](LICENSE) [![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://imdocs.readthedocs.io/en/latest/client.html) From b72d7c0143f20d10c026981294506d738c01146e Mon Sep 17 00:00:00 2001 From: micafer Date: Thu, 3 Mar 2022 10:57:51 +0100 Subject: [PATCH 3/3] Change REST path to authorization --- im_client.py | 2 +- test/files/auth_new.dat | 1 + test/unit/test_client.py | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/files/auth_new.dat diff --git a/im_client.py b/im_client.py index b2f388b..221e459 100755 --- a/im_client.py +++ b/im_client.py @@ -920,7 +920,7 @@ def change_auth(self): if self.options.restapi: headers = {"Authorization": self.rest_auth_data} - url = "%s/infrastructures/%s/authentication" % (self.options.restapi, inf_id) + url = "%s/infrastructures/%s/authorization" % (self.options.restapi, inf_id) if overwrite: url += "?overwrite=1" resp = requests.request("POST", url, verify=self.options.verify, diff --git a/test/files/auth_new.dat b/test/files/auth_new.dat new file mode 100644 index 0000000..58d6e18 --- /dev/null +++ b/test/files/auth_new.dat @@ -0,0 +1 @@ +type = InfrastructureManager; username = user1; password = pass1 diff --git a/test/unit/test_client.py b/test/unit/test_client.py index fc88090..59ee50f 100755 --- a/test/unit/test_client.py +++ b/test/unit/test_client.py @@ -116,6 +116,9 @@ def get_response(method, url, verify, cert=None, headers=None, data=None): resp.status_code = 200 resp.text = ('{ "uri-list": [ { "uri" : "http://localhost/infid/vms/1" }]}') resp.json.return_value = json.loads(resp.text) + elif url == "/infrastructures/infid/authorization": + resp.status_code = 200 + resp.text = "" else: resp.status_code = 404 elif method == "DELETE": @@ -1191,6 +1194,21 @@ def test_create_wait_outputs(self, requests): self.assertEqual(output, {"infid": "inf1", "output1": "value1" , "output2": "value2"}) sys.stdout = oldstdout + @patch('requests.request') + def test_change_user(self, requests): + """ + Test create_wait_outputs operation + """ + requests.side_effect = self.get_response + options = MagicMock() + options.auth_file = get_abs_path("../../auth.dat") + options.restapi = "https://localhost:8800" + options.xmlrpc = None + options.quiet = True + parser = MagicMock() + + res = main("change_auth", options, ["infid", get_abs_path("../files/auth_new.dat")], parser) + self.assertEquals(res, True) if __name__ == '__main__':