Reputation: 680
I am developing authentication system using Oauth protocol and as per the Oauth standard, Once you send an authentication request to your server, In response you get some set of oauth parameters including signature, timestamp, nonce, etc. Now my question is, How do I write PHPUnit testcases to validate if expected parameters are in place (please note that parameters can come in headers or in body or in querystring). After parameter validation, I also need to validate signature I received in response using my signature calculation method.
I am stuck at how do I mock response to validate parameters and then signature.
Thanks in advance.
Upvotes: 1
Views: 785
Reputation: 38981
From what i understood you want to write a unit test for your client to see if it correctly parses the response messages from the oauth server.
So you'd need to "mock" the server. (Or rather the method that fetches the values from the server).
You could create some fake "reponse" xml files and pass them to the class that is concerned with reading the response.
So you have your Response class that has a ->getHeaders, ->getQueryString and ->getBody (I just make assumptions here) and you need to mock those methods out to test your "parsing" logic.
I hope i got your question. If not let me know and maybe show an example? :)
Upvotes: 2