apache / cloudstack

Apache CloudStack is an opensource Infrastructure as a Service (IaaS) cloud computing platform
https://cloudstack.apache.org/
Apache License 2.0
1.97k stars 1.09k forks source link

API testability - need a cURL request generator? #8231

Open synergiator opened 10 months ago

synergiator commented 10 months ago
ISSUE TYPE
COMPONENT NAME
API
CLOUDSTACK VERSION
any
OS / ENVIRONMENT
SUMMARY

How do you test the API in troubleshooting sitations? For example, today I've looked to simulate a deployVM request with a large user data, and discovered that:

Also in other situation, sometimes doubts can come up - maybe it's a problem with the client software layer, not the API?

Given that, to create a cURL request is not trivial because credentials are applied for security reasons as a cryptographic signature.

Here is for reference purposes a fragment from the exoscale/cs auth/signing code:

 def _sign(self, data):
        """
        Compute a signature string according to the CloudStack
        signature method (hmac/sha1).
        """
        # Python2/3 urlencode aren't good enough for this task.
        params = "&".join(
            "=".join((key, cs_encode(value)))
            for key, value in sorted(data.items())
        )

        digest = hmac.new(
            self.secret.encode("utf-8"),
            msg=params.lower().encode("utf-8"),
            digestmod=hashlib.sha1,
        ).digest()

        data["signature"] = base64.b64encode(digest).decode("utf-8").strip()

Maybe there is a tool around to formulate any cURL request in question for the CloudStack API? or maybe this is a feature to implement for the CloudMonkey printout, as debug either output flavour?

synergiator commented 10 months ago

Note: cs/exoscale does support POST.

cs = CloudStack(..., method='post'), 
DaanHoogland commented 7 months ago

@synergiator , can you explain what you expect with this ticket? It seems that you reference several issues/implementations that already satisfy your concerns here.