|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/owens.enteract/inc/libs/rackspace/tests/ |
Upload File : |
<?php # -*- compile-command: (concat "phpunit " buffer-file-name) -*-
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set("display_errors", 1);
set_time_limit(0); //No script timeout�
require_once 'PHPUnit/Framework.php';
require_once 'common.php';
class Authentication extends PHPUnit_Framework_TestCase
{
function __construct() {
$this->auth = null;
}
protected function setUp() {
$this->auth = new CF_Authentication(USER, API_KEY);
$this->auth->authenticate();
$conn = new CF_Connection($this->auth);
}
public function testTokenCache()
{
$this->auth = new CF_Authentication(USER, API_KEY);
$this->auth->authenticate();
$arr = $this->auth->export_credentials();
$this->assertNotNull($arr['storage_url']);
$this->assertNotNull($arr['cdnm_url']);
$this->assertNotNull($arr['auth_token']);
}
public function testTokenAuth()
{
$this->auth = new CF_Authentication(USER, API_KEY);
$this->auth->authenticate();
$arr = $this->auth->export_credentials();
$this->assertNotNull($arr['storage_url']);
$this->assertNotNull($arr['cdnm_url']);
$this->assertNotNull($arr['auth_token']);
$this->auth = new CF_Authentication();
$this->auth->load_cached_credentials($arr['auth_token'], $arr['storage_url'], $arr['cdnm_url']);
$conn = new CF_Connection($this->auth);
}
public function testTokenErrors()
{
$auth = new CF_Authentication(USER, API_KEY);
$auth->authenticate();
$arr = $auth->export_credentials();
$this->assertNotNull($arr['storage_url']);
$this->assertNotNull($arr['cdnm_url']);
$this->assertNotNull($arr['auth_token']);
$this->auth = new CF_Authentication();
$this->setExpectedException('SyntaxException');
$auth->load_cached_credentials(NULL, $arr['storage_url'], $arr['cdnm_url']);
$this->setExpectedException('SyntaxException');
$auth->load_cached_credentials($arr['auth_token'], NULL, $arr['cdnm_url']);
$this->setExpectedException('SyntaxException');
$auth->load_cached_credentials($arr['auth_token'], $arr['storage_url'], NULL);
}
public function testBadAuthentication()
{
$this->setExpectedException('AuthenticationException');
$auth = new CF_Authentication('e046e8db7d813050b14ce335f2511e83', 'bleurrhrhahra');
$auth->authenticate();
}
public function testAuthenticationAttributes()
{
$this->assertNotNull($this->auth->storage_url);
$this->assertNotNull($this->auth->auth_token);
if (ACCOUNT)
$this->assertNotNull($this->auth->cdnm_url);
}
public function testUkAuth()
{
$this->assertTrue(UK_AUTHURL
== 'https://lon.auth.api.rackspacecloud.com');
}
}
?>