Skip to content
Snippets Groups Projects
Commit 07851c0e authored by Andrew Hoffmann's avatar Andrew Hoffmann
Browse files

When receiving 4xx responses from checkLOA, the client will return a...

When receiving 4xx responses from checkLOA, the client will return a RpcNetidStructValidationResponse with valid = false instead of throwing an exception. 4xx are not considered "unexpected states". We need to be consistent on the return type at some point.  (405 returns an integere, all the rest return a string).
parent bcca3676
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/.project /.project
/.settings /.settings
/.vagrant /.vagrant
/.idea
/composer.lock /composer.lock
/vendor /vendor
/composer.phar /composer.phar
......
...@@ -131,20 +131,20 @@ class RpcNetidClientSoap implements RpcNetidClient { ...@@ -131,20 +131,20 @@ class RpcNetidClientSoap implements RpcNetidClient {
return new RpcNetidStructValidationResponse(false, array()); return new RpcNetidStructValidationResponse(false, array());
break; break;
case 401: case 401:
throw new RpcNetidClientSoapException("Web service returned 401: invalid input parameters", return new RpcNetidStructValidationResponse( false, array("Web service returned 401: invalid input
RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE ); parameters"));
break; break;
case 402: case 402:
throw new RpcNetidClientSoapException("Web service returned 402: no PVI found for uid", return new RpcNetidStructValidationResponse( false, array("Web service returned 402: no PVI found for
RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE ); uid") );
break; break;
case 403: case 403:
throw new RpcNetidClientSoapException("Web service returned 403: no LOA found for uid", return new RpcNetidStructValidationResponse( false, array("Web service returned 403: no LOA found for
RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE ); uid") );
break; break;
case 404: case 404:
throw new RpcNetidClientSoapException("Web service returned 404: no Wiscard eligibility data found for uid", return new RpcNetidStructValidationResponse( false, array("Web service returned 404: no Wiscard
RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE ); eligibility data found for uid"));
break; break;
case 405: case 405:
return new RpcNetidStructValidationResponse(false, array(RpcNetidStructValidationResponse::REASON_NEEDS_WISCARD ) ); return new RpcNetidStructValidationResponse(false, array(RpcNetidStructValidationResponse::REASON_NEEDS_WISCARD ) );
......
...@@ -564,66 +564,66 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -564,66 +564,66 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
} }
/** /**
* @test throws exception if web service returns 401 (invalid parameters) * @test returns false if web service returns 401 (invalid parameters)
* @expectedException edu\wisc\doit\RpcNetidClientSoapException
* @expectedExceptionCode 100
*/ */
function checkLOA_401_throws() { function checkLOA_401_returns_false() {
$result = new stdClass(); $result = new stdClass();
$result->result = 401; $result->result = 401;
$this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient); $client = new RpcNetidClientSoap($this->mockSoapClient);
$client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() );
} }
/** /**
* @test throws exception if web service returns 402 (No PVI found for UID) * @test returns false if web service returns 402 (No PVI found for UID)
* @expectedException edu\wisc\doit\RpcNetidClientSoapException
* @expectedExceptionCode 100
*/ */
function checkLOA_402_throws() { function checkLOA_402_returns_false() {
$result = new stdClass(); $result = new stdClass();
$result->result = 402; $result->result = 402;
$this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient); $client = new RpcNetidClientSoap($this->mockSoapClient);
$client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() );
} }
/** /**
* @test throws exception if web service returns 403 (No LOA found for UID) * @test returns false if web service returns 403 (No LOA found for UID)
* @expectedException edu\wisc\doit\RpcNetidClientSoapException
* @expectedExceptionCode 100
*/ */
function checkLOA_403_throws() { function checkLOA_403_returns_false() {
$result = new stdClass(); $result = new stdClass();
$result->result = 403; $result->result = 403;
$this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient); $client = new RpcNetidClientSoap($this->mockSoapClient);
$client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() );
} }
/** /**
* @test throws exception if web service returns 404 (No Wiscard eligibility found for user) * @test returns false if web service returns 404 (No Wiscard eligibility found for user)
* @expectedException edu\wisc\doit\RpcNetidClientSoapException
* @expectedExceptionCode 100
*/ */
function checkLOA_404_throws() { function checkLOA_404_returns_false() {
$result = new stdClass(); $result = new stdClass();
$result->result = 404; $result->result = 404;
$this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient); $client = new RpcNetidClientSoap($this->mockSoapClient);
$client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment