diff --git a/src/main/edu/wisc/doit/RpcNetidClient.php b/src/main/edu/wisc/doit/RpcNetidClient.php index 7a6a9004cdcaeb1ca61cc58e9a89f463fc41dc69..db9eb30b37b0409cc7d94a709076a48c207a3e05 100644 --- a/src/main/edu/wisc/doit/RpcNetidClient.php +++ b/src/main/edu/wisc/doit/RpcNetidClient.php @@ -1,10 +1,4 @@ -<?php - -/** - * RpcNetidClient interface - */ - -namespace edu\wisc\doit; +<?php namespace edu\wisc\doit; /** * A PHP client for the NetID web service provided by DoIT Middleware. @@ -39,7 +33,7 @@ interface RpcNetidClient { * @param string $uid the uid of the user to search for (typically the NetID) * @param string $password the password to be checked for policy adherence and replace current password * @return bool true if password was changed successfully, false otherwise - * @throws edu\wisc\doit\RpcNetidClientSoapException if unexpected response code from SOAP service + * @throws RpcNetidClientSoapException if unexpected response code from SOAP service */ function changePassword ( $uid, $password ); @@ -49,7 +43,7 @@ interface RpcNetidClient { * @param RpcNetidStructQuestion[] $questions array containing security questions for the user (Number and Answer required) * @param string $ip ip address of the user * @return bool true if the answers are correct, false otherwise - * @throws edu\wisc\doit\RpcNetidClientSoapException if unexpected response from web service + * @throws RpcNetidClientSoapException if unexpected response from web service */ function checkAnswers ( $uid, array $questions, $ip ); @@ -102,7 +96,7 @@ interface RpcNetidClient { * * @param string $uid user's NetID * @param \DateTime $birthdate user's date of birth - * @param int $wiscard user's 11-digit Wiscard number + * @param string $wiscard user's 11-digit Wiscard number * @return RpcNetidStructValidationResponse validation response including reasons for failure. */ function checkLOA( $uid, \DateTime $birthdate, $wiscard = null ); diff --git a/src/main/edu/wisc/doit/RpcNetidClientSoap.php b/src/main/edu/wisc/doit/RpcNetidClientSoap.php index 7f72644f3776ba64038f17c0d2a03452c65cfbe8..c522dec4d00e14669818f90eee0e1654ae5520ae 100644 --- a/src/main/edu/wisc/doit/RpcNetidClientSoap.php +++ b/src/main/edu/wisc/doit/RpcNetidClientSoap.php @@ -100,22 +100,19 @@ class RpcNetidClientSoap implements RpcNetidClient { public function checkLOA( $uid, \DateTime $birthdate, $wiscard = null ) { if ( is_string( $uid ) !== true or empty( $uid ) === true ) { - throw new \InvalidArgumentException( "uid must be a nonempty string" ); + throw new \InvalidArgumentException( "uid must be a nonempty string. Type given: " . gettype($uid) ); } if ( is_null( $wiscard ) === false ) { - if ( is_int( $wiscard ) !== true ) { - throw new \InvalidArgumentException( "wiscard must be at least a 10-digit integer"); - } - if ( strlen(strval($wiscard)) < 10 ) { - throw new \DomainException( "wiscard must be at least a 10-digit integer"); + if ( is_string( $wiscard ) !== true ) { + throw new \InvalidArgumentException( "wiscard must be a string. Type given: " . gettype($wiscard) ); } } $parameters = array(); $parameters['uid'] = strval( $uid ); $parameters['birthdate'] = $birthdate->format("m-d-Y"); - if ( is_null( $wiscard ) === false ) { $parameters['cardid'] = strval( $wiscard ); } + if ( is_null( $wiscard ) === false ) { $parameters['cardid'] = $wiscard; } $result = $this->getSoapClient()->checkLOA( $parameters ); diff --git a/src/test/RpcNetidClientSoapTest.php b/src/test/RpcNetidClientSoapTest.php index 06e6761b3eda7ee89d829e167ec1f94effd4dd17..3f3d956b0ef6b8a838fdea4a82b110af77c381ff 100644 --- a/src/test/RpcNetidClientSoapTest.php +++ b/src/test/RpcNetidClientSoapTest.php @@ -532,21 +532,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { /* checkLOA tests ------------------------------- */ - /** - * @test Wiscard is less than 10 digits throws exception - * @expectedException DomainException - */ - function checkLOA_wiscard_less_than_10_digits_throws() { - - $result = new stdClass(); - $result->result = 200; - - $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); - $client = new RpcNetidClientSoap($this->mockSoapClient); - $client->checkLOA( "jsmith", new \DateTime(), 12345 ); - - } - /** * @test returns false if 400 is returned by web service */ @@ -557,7 +542,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertFalse( $returned->getIsValid() ); @@ -573,7 +558,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertFalse( $returned->getIsValid() ); @@ -589,7 +574,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertFalse( $returned->getIsValid() ); @@ -605,7 +590,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertFalse( $returned->getIsValid() ); @@ -621,7 +606,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertFalse( $returned->getIsValid() ); @@ -655,7 +640,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertTrue( $returned->getIsValid() ); @@ -673,7 +658,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $client->checkLOA( "jsmith", new \DateTime(), "12345678901" ); }