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

Changed the $wiscard parameter to a string in checkLOA() to match the WSDL and...

Changed the $wiscard parameter to a string in checkLOA() to match the WSDL and to avoid integer overflow with 11 digits.

ACCTREC-299
parent 0b187bfc
No related branches found
No related tags found
No related merge requests found
<?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 );
......
......@@ -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 );
......
......@@ -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" );
}
......
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