My first approach was to create an account on MyOpenID and to define the login sequence with Selenium. It worked the first time I tried to login. But as MyOpenID sets a cookie after the login, the login form was no longer shown in subsequent login approaches, and so the Selenium test failed… Maybe I could have solved this problem with Selenium, but as the entire process was rather slow I decided to look for another solution.
// add this snippet after user_session(); $_SESSION['auth_username'] = $profile['auth_username']; $_SESSION['auth_url'] = $profile['idp_url']; wrap_refresh($_SESSION['post_auth_url']);
To use this script with CakePHP I put it into app/webroot and use the following snippet in my Selenium test case to log into my application:
$this->open('http://myproject.localhost/users/login'); $this->type('name=data[User][openid]', 'http://myproject.localhost/MyID.php'); $this->click('submit'); $this->waitForCondition('parent.myiframe.location.href == "http://myproject.localhost/projects"', '10000');
You can also rename the MyID.php file if you want a more descriptive name, and if you want to use multiple IDs simply copy MyID.php as often as you need.
Happy testing :)