_tempDir = APP_DIR . '/tests/temp'; } public function setUp() { TestHarness::setUp(); Application::$front->returnResponse(true); $this->_response = new Zend_Controller_Response_Http(); Application::$front->setResponse($this->_response); $users = new Users_Model_Users(); $this->_user = $users->createRow(); $this->_user->test = 1; $this->_user->username = 'testuser'; $this->_user->role = Users_Model_User::ROLE_REGISTERED; $this->_user->openid = 'http://localhost/communityid/identity/'.$this->_user->username; $this->_user->accepted_eula = 1; $this->_user->firstname = 'firstnametest'; $this->_user->lastname = 'lastnametest'; $this->_user->email = 'usertest@mailinator.com'; $this->_user->token = ''; $this->_user->save(); Zend_Registry::set('user', $this->_user); } /** * @expectedException Monkeys_BadUrlException */ public function testIndexAction() { Application::$front->setRequest(new TestRequest('/openid')); Application::dispatch(); } public function testProviderAssociateAction() { $_POST = array( 'openid_ns' => 'http://specs.openid.net/auth/2.0', 'openid_mode' => 'associate', 'openid_assoc_type' => 'HMAC-SHA256', 'openid_session_type' => 'DH-SHA256', 'openid_dh_modulus' => 'ANz5OguIOXLsDhmYmsWizjEOHTdxfo2Vcbt2I3MYZuYe91ouJ4mLBX+YkcLiemOcPym2CBRYHNOyyjmG0mg3BVd9RcLn5S3IHHoXGHblzqdLFEi/368Ygo79JRnxTkXjgmY0rxlJ5bU1zIKaSDuKdiI+XUkKJX8Fvf8W8vsixYOr', 'openid_dh_gen' => 'Ag==', 'openid_dh_consumer_public' => 'MFzHUMsSa4YSQ3JrcPSqyUaTQ3Z+QWKH6knvrREW7b6zQ2qMdOrpckgnUgo0pILMQpls8Ty/3JDv+IO29qASk2PwwZwxC2kXK/MQC/om5gs/IpjPSw1wK4bz2QTUHTRSxmtTxiq0tHYmIIqadz4TTMfXohMU2VCuYBqDNMHZFpk=', ); // needed by Zend_OpenId_Provider $_SERVER["REQUEST_METHOD"] = 'POST'; Application::$front->setRequest(new TestRequest('/openid/provider')); Application::dispatch(); $this->assertEquals( preg_match( "% ns:http://specs\.openid\.net/auth/2\.0\\x0A assoc_type:HMAC-SHA256\\x0A session_type:DH-SHA256\\x0A dh_server_public:.*\\x0A enc_mac_key:.*\\x0A assoc_handle:([a-f0-9]+)\\x0A expires_in:3600\\x0A %x", $this->_response->getBody(), $matches ), 1 ); self::$assocHandle = $matches[1]; } public function testProviderCheckidSetupAction() { // needed by Zend_OpenId_Provider $_SERVER["REQUEST_METHOD"] = 'GET'; Zend_OpenId::$exitOnRedirect = false; Application::$front->setRequest(new TestRequest('/openid/provider?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.identity=http%3A%2F%2Flocalhost%2Fcommunityid%2Fidentity%2Ftestuser&openid.claimed_id=http%3A%2F%2Flocalhost%2Fcommunityid%2Fidentity%2Ftestuser&openid.assoc_handle='.self::$assocHandle.'&openid.return_to=http%3A%2F%2Fwww%2Eexample%2Ecom&openid.realm=http%3A%2F%2Fwww%2Eexample%2Ecom')); Application::dispatch(); $this->assertEquals( preg_match( '# #x', $this->_response->getBody() ), 1 ); } public function testLoginAction() { $_SERVER['QUERY_STRING'] = sprintf(self::CHECKID_QUERY, self::$assocHandle); Application::$front->setRequest(new TestRequest('/openid/login?' . $_SERVER['QUERY_STRING'])); Application::dispatch(); $this->assertContains('