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

Added the checkLOA method to the RpcNetidClient interface. Created a

skeleton implementation in RpcNetidClientSoap. Created the unit tests
for the new method, which are all failing at this point.
parent 3883567c
No related branches found
No related tags found
No related merge requests found
......@@ -90,6 +90,26 @@ interface RpcNetidClient {
* @return RpcNetidStructValidationResponse indicates if valid and the reason for invalid
*/
function passwordChoicePolicyCheck( $password );
/**
* Verifies the identity of a UW-Madison user using his or her NetID, date of birth,
* and optional Wiscard number.
*
* <p>This method will take into account the user's LOA (level of assurance). If the user
* is LOA2 or higher, the WisCard number is required. Otherwise, it is ignored.</p>
*
* <p>The method returns a {@link RpcNetidStructValidationResponse} object. If
* {@link RpcNetidStructValidationResponse::getIsValid} returns true, the identity is verified.
* Otherwise, it will return false with zero or more reasons returned by
* {@link RpcNetidStructValidationResponse::getReasons}
*
* @param string $uid user's NetID
* @param \DateTime $birthdate user's date of birth
* @param int $wiscard user's 11-digit Wiscard number
* @return RpcNetidStructValidationResponse validation response including reasons for failure.
*/
function checkLOA( $uid, \DateTime $birthdate, $wiscard = null );
}
/**
......
......@@ -123,6 +123,16 @@ class RpcNetidClientSoap implements RpcNetidClient {
throw new RpcNetidClientSoapException("Unexpected status code: {$result->result}",
RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE );
}
/**
* (non-PHPdoc)
* @see \edu\wisc\doit\RpcNetidClient::checkLOA()
*/
public function checkLOA( $uid, \DateTime $birthdate, $wiscard = null ) {
}
/**
......@@ -360,7 +370,7 @@ class RpcNetidClientSoap implements RpcNetidClient {
* Exception class for {@link RpcNetidClientSoap}
*/
class RpcNetidClientSoapException extends RpcNetidClientException {
const UNEXPECTED_STATUS_CODE = 100;
const UNEXPECTED_RESPONSE = 101;
const UNEXPECTED_STATUS_CODE = 100; // web service returns status code that cannot be handled (runtime exception)
const UNEXPECTED_RESPONSE = 101; // web service returns content that is not expected
const INVALID_EMAIL = 102;
}
\ No newline at end of file
......@@ -602,5 +602,152 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$this->assertTrue($returnValue->getIsValid());
}
/* checkLOA tests ------------------------------- */
/**
* @test Wiscard is not 11 digits throws exception
* @expectedException DomainException
*/
function checkLOA_wiscard_not_11_digits_throws() {
$result = new stdClass();
$result->result = 200;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->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
*/
function checkLOA_400_returns_false() {
$result = new stdClass();
$result->result = 400;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$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 401 (invalid parameters)
* @expectedException RpcNetidClientSoapException
* @expectedExceptionCode 100
*/
function checkLOA_401_throws() {
$result = new stdClass();
$result->result = 401;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
}
/**
* @test throws exception if web service returns 402 (No PVI found for UID)
* @expectedException RpcNetidClientSoapException
* @expectedExceptionCode 100
*/
function checkLOA_402_throws() {
$result = new stdClass();
$result->result = 402;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
}
/**
* @test throws exception if web service returns 403 (No LOA found for UID)
* @expectedException RpcNetidClientSoapException
* @expectedExceptionCode 100
*/
function checkLOA_403_throws() {
$result = new stdClass();
$result->result = 403;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
}
/**
* @test throws exception if web service returns 404 (No Wiscard eligibility found for user)
* @expectedException RpcNetidClientSoapException
* @expectedExceptionCode 100
*/
function checkLOA_404_throws() {
$result = new stdClass();
$result->result = 404;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
}
/**
* @test returns false validation object with reason if web service returns 405 (Person is LOA2, but the Wiscard was missing)
*/
function checkLOA_405_returns_false_with_reason() {
$result = new stdClass();
$result->result = 405;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$returned = $client->checkLOA( "jsmith", new \DateTime() );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertFalse( $returned->getIsValid() );
$this->assertNotEmpty( $returned->getReasons() );
}
/**
* @test returns true validation object when web service returns 200
*/
function checkLOA_200_returns_true() {
$result = new stdClass();
$result->result = 200;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 );
$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
$this->assertTrue( $returned->getIsValid() );
}
/**
* @test throws exception if an unexpected response code was received by web service
* @expectedException RpcNetidClientSoapException
* @expectedExceptionCode 100
*/
function checkLOA_500_throws_exception() {
$result = new stdClass();
$result->result = 500;
$this->mockSoapClient->expects($this->any())->method('passwordChoicePolicyCheck')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$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