summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2007-09-19 19:46:41 +0000
committertailor <cygnus@janrain.com>2007-09-19 19:46:41 +0000
commit711756348c34631b35b75746677834e014325b84 (patch)
treef227b88c15ffea00f6d2936e907851197f01051a
parentd4c9aaaa2ec195a6ba7ad72c8532de64b6560a8a (diff)
downloadphp-openid-711756348c34631b35b75746677834e014325b84.zip
php-openid-711756348c34631b35b75746677834e014325b84.tar.gz
php-openid-711756348c34631b35b75746677834e014325b84.tar.bz2
[project @ FIX #28: fixed append() call and added failed discovery verification test]
-rw-r--r--Auth/OpenID/Consumer.php5
-rw-r--r--Tests/Auth/OpenID/VerifyDisco.php58
2 files changed, 58 insertions, 5 deletions
diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php
index d75b842..4bc62cc 100644
--- a/Auth/OpenID/Consumer.php
+++ b/Auth/OpenID/Consumer.php
@@ -1067,14 +1067,11 @@ class Auth_OpenID_GenericConsumer {
// Search the services resulting from discovery to find one
// that matches the information from the assertion
- $failure_messages = array();
foreach ($services as $endpoint) {
$result = $this->_verifyDiscoverySingle($endpoint, $to_match);
- if (Auth_OpenID::isFailure($result)) {
- $failure_messages->append($result);
- } else {
+ if (!Auth_OpenID::isFailure($result)) {
// It matches, so discover verification has
// succeeded. Return this endpoint.
return $endpoint;
diff --git a/Tests/Auth/OpenID/VerifyDisco.php b/Tests/Auth/OpenID/VerifyDisco.php
index e4ed3ce..a3a6277 100644
--- a/Tests/Auth/OpenID/VerifyDisco.php
+++ b/Tests/Auth/OpenID/VerifyDisco.php
@@ -163,6 +163,15 @@ class Tests_openID2NoEndpointDoesDisco_sentinel extends Auth_OpenID_GenericConsu
}
}
+class Tests_openID2NoEndpointDoesDisco_failure extends Auth_OpenID_GenericConsumer {
+ var $failure_message = 'A fake failure response message';
+
+ function _verifyDiscoverySingle($to_match)
+ {
+ return new Auth_OpenID_FailureResponse(null, $this->failure_message);
+ }
+}
+
class Tests_openID2NoEndpointDoesDisco extends Tests_Auth_OpenID_VerifyDisco {
var $consumer_class = 'Tests_openID2NoEndpointDoesDisco_sentinel';
@@ -203,6 +212,52 @@ class Tests_openID2MismatchedDoesDisco extends Tests_Auth_OpenID_VerifyDisco {
}
}
+class Tests_openID2MismatchedDoesDisco_failure extends PHPUnit_TestCase {
+ var $consumer_class = 'Tests_openID2NoEndpointDoesDisco_failure';
+
+ function setUp()
+ {
+ $this->store = new Tests_Auth_OpenID_MemStore();
+ $cl = $this->consumer_class;
+ $this->consumer = new $cl($this->store);
+ $this->return_to = "http://some.host/path";
+ $this->endpoint = new Auth_OpenID_ServiceEndpoint();
+
+ $this->consumer->discoverMethod = array($this, "_getServices");
+
+ $this->server_id = "sirod";
+ $this->server_url = "serlie";
+ $this->consumer_id = "consu";
+
+ $this->endpoint->claimed_id = $this->consumer_id;
+ $this->endpoint->server_url = $this->server_url;
+ $this->endpoint->local_id = $this->server_id;
+ $this->endpoint->type_uris = array(Auth_OpenID_TYPE_1_1);
+ }
+
+ function _getServices($claimed_id, $fetcher=null) {
+ return array(null, array($this->endpoint));
+ }
+
+ function test_openID2MismatchedDoesDisco_failure()
+ {
+ $mismatched = new Auth_OpenID_ServiceEndpoint();
+ $mismatched->identity = 'nothing special, but different';
+ $mismatched->local_id = 'green cheese';
+
+ $op_endpoint = 'Phone Home';
+
+ $msg = Auth_OpenID_Message::fromOpenIDArgs(
+ array('ns' => Auth_OpenID_OPENID2_NS,
+ 'identity' => 'sour grapes',
+ 'claimed_id' => 'monkeysoft',
+ 'op_endpoint' => $op_endpoint));
+
+ $result = $this->consumer->_verifyDiscoveryResults($msg, $mismatched);
+ $this->assertTrue(Auth_OpenID::isFailure($result));
+ }
+}
+
class TestVerifyDiscoverySingle extends OpenIDTestMixin {
var $consumer_class = 'Auth_OpenID_GenericConsumer';
@@ -247,7 +302,8 @@ class TestVerifyDiscoverySingle extends OpenIDTestMixin {
global $Tests_Auth_OpenID_VerifyDisco_other;
$Tests_Auth_OpenID_VerifyDisco_other = array(
new Tests_openID2MismatchedDoesDisco(),
- new Tests_openID2NoEndpointDoesDisco()
+ new Tests_openID2NoEndpointDoesDisco(),
+ new Tests_openID2MismatchedDoesDisco_failure(),
);
?> \ No newline at end of file