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

Merged in ahoffmann_wisc/rpc-netid-php/ACCTREC-299 (pull request #3)

ACCTREC-299: Represent Wiscard as string instead of integer
parents b8d11ad0 a62343ba
No related branches found
No related tags found
No related merge requests found
<?php <?php namespace edu\wisc\doit;
/**
* RpcNetidClient interface
*/
namespace edu\wisc\doit;
/** /**
* A PHP client for the NetID web service provided by DoIT Middleware. * A PHP client for the NetID web service provided by DoIT Middleware.
...@@ -39,7 +33,7 @@ interface RpcNetidClient { ...@@ -39,7 +33,7 @@ interface RpcNetidClient {
* @param string $uid the uid of the user to search for (typically the NetID) * @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 * @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 * @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 ); function changePassword ( $uid, $password );
...@@ -49,7 +43,7 @@ interface RpcNetidClient { ...@@ -49,7 +43,7 @@ interface RpcNetidClient {
* @param RpcNetidStructQuestion[] $questions array containing security questions for the user (Number and Answer required) * @param RpcNetidStructQuestion[] $questions array containing security questions for the user (Number and Answer required)
* @param string $ip ip address of the user * @param string $ip ip address of the user
* @return bool true if the answers are correct, false otherwise * @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 ); function checkAnswers ( $uid, array $questions, $ip );
...@@ -102,7 +96,7 @@ interface RpcNetidClient { ...@@ -102,7 +96,7 @@ interface RpcNetidClient {
* *
* @param string $uid user's NetID * @param string $uid user's NetID
* @param \DateTime $birthdate user's date of birth * @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. * @return RpcNetidStructValidationResponse validation response including reasons for failure.
*/ */
function checkLOA( $uid, \DateTime $birthdate, $wiscard = null ); function checkLOA( $uid, \DateTime $birthdate, $wiscard = null );
......
...@@ -100,22 +100,19 @@ class RpcNetidClientSoap implements RpcNetidClient { ...@@ -100,22 +100,19 @@ class RpcNetidClientSoap implements RpcNetidClient {
public function checkLOA( $uid, \DateTime $birthdate, $wiscard = null ) { public function checkLOA( $uid, \DateTime $birthdate, $wiscard = null ) {
if ( is_string( $uid ) !== true or empty( $uid ) === true ) { 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_null( $wiscard ) === false ) {
if ( is_int( $wiscard ) !== true ) { if ( is_string( $wiscard ) !== true ) {
throw new \InvalidArgumentException( "wiscard must be at least a 10-digit integer"); throw new \InvalidArgumentException( "wiscard must be a string. Type given: " . gettype($wiscard) );
}
if ( strlen(strval($wiscard)) < 10 ) {
throw new \DomainException( "wiscard must be at least a 10-digit integer");
} }
} }
$parameters = array(); $parameters = array();
$parameters['uid'] = strval( $uid ); $parameters['uid'] = strval( $uid );
$parameters['birthdate'] = $birthdate->format("m-d-Y"); $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 ); $result = $this->getSoapClient()->checkLOA( $parameters );
......
...@@ -532,21 +532,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -532,21 +532,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
/* checkLOA tests ------------------------------- */ /* 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 * @test returns false if 400 is returned by web service
*/ */
...@@ -557,7 +542,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -557,7 +542,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$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);
$returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() ); $this->assertFalse( $returned->getIsValid() );
...@@ -573,7 +558,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -573,7 +558,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$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);
$returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() ); $this->assertFalse( $returned->getIsValid() );
...@@ -589,7 +574,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -589,7 +574,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$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);
$returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() ); $this->assertFalse( $returned->getIsValid() );
...@@ -605,7 +590,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -605,7 +590,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$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);
$returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() ); $this->assertFalse( $returned->getIsValid() );
...@@ -621,7 +606,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -621,7 +606,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$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);
$returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() ); $this->assertFalse( $returned->getIsValid() );
...@@ -655,7 +640,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -655,7 +640,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$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);
$returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); $returned = $client->checkLOA( "jsmith", new \DateTime(), "12345678901" );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertTrue( $returned->getIsValid() ); $this->assertTrue( $returned->getIsValid() );
...@@ -673,7 +658,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -673,7 +658,7 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$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 ); $client->checkLOA( "jsmith", new \DateTime(), "12345678901" );
} }
......
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