function testExpiredSession()
 {
     $session = $this->objFromFixture('AuthSession', 'expired');
     $this->assertEquals(false, $session->IsValid());
     $res = ApiControllerTest::send_test('GET', 'auth/session/', null, $session->Accesstoken());
     $session = $this->objFromFixture('AuthSession', 'valid');
     $this->assertEquals(true, $session->IsValid());
     $res = ApiControllerTest::send_test('GET', 'auth/session/', null, $session->Accesstoken());
 }
 /**
  * We check some basic methods of the ApiController (as functional tests, not unit tests for now)
  * TODO: replace with unit tests maybe …
  * e.g. checkAccessAction, checkPermission …
  */
 function testResponseTypes()
 {
     $invalidAccessToken = sha1(rand(0, 10000) . time());
     $adminAccessToken = Config::inst()->get('AuthSession', 'adminAccessToken');
     $expectJSON = false;
     $msgValidSession = "This data should only be seen if we have a valid session";
     $res = ApiControllerTest::send_test('GET', 'auth/testIsValidSession', $data = null, $invalidAccessToken, $expectJSON);
     // $this->assertEquals($res['body'], "Action 'testIsValidSession' isn't allowed on class AuthController.");
     $this->assertEquals($res['statusCode'], 403);
     $res = ApiControllerTest::send_test('GET', 'auth/testIsValidSession', $data = null, $adminAccessToken);
     $this->assertEquals($res['data']['message'], $msgValidSession);
     $this->assertEquals($res['statusCode'], 200);
     $res = ApiControllerTest::send_test('GET', 'auth/testAPIPermission', $data = null, $invalidAccessToken, $expectJSON);
     // $this->assertEquals($res['body'], "Action 'testAPIPermission' isn't allowed on class AuthController.");
     $this->assertEquals($res['statusCode'], 403);
     $session = $this->objFromFixture('AuthSession', 'api');
     $res = ApiControllerTest::send_test('GET', 'auth/testAPIPermission', $data = null, $session->Accesstoken());
     $this->assertEquals($res['data']['message'], $msgValidSession);
     $this->assertEquals($res['statusCode'], 200);
     $res = ApiControllerTest::send_test('GET', 'auth/testADMINPermission', $data = null, $session->Accesstoken(), $expectJSON);
     $this->assertEquals($res['statusCode'], 403);
     $session = $this->objFromFixture('AuthSession', 'valid');
     $res = ApiControllerTest::send_test('GET', 'auth/testADMINPermission', $data = null, $session->Accesstoken());
     $this->assertEquals($res['data']['message'], $msgValidSession);
     $this->assertEquals($res['statusCode'], 200);
     $res = ApiControllerTest::send_test('GET', 'auth/testADMINPermission', $data = null, $adminAccessToken, $expectJSON);
     $this->assertEquals($res['data']['message'], $msgValidSession);
     $this->assertEquals($res['statusCode'], 200);
     $res = ApiControllerTest::send_test('GET', 'auth/testAPIPermission', $data = null, $session->Accesstoken());
     $this->assertEquals($res['statusCode'], 200);
     $res = ApiControllerTest::send_test('GET', 'auth/testADMINPermission', $data = null, $adminAccessToken);
     $this->assertEquals($res['data']['message'], $msgValidSession);
     $this->assertEquals($res['statusCode'], 200);
     $res = ApiControllerTest::send_test('GET', 'auth/testPermissionFailure', $data = null, $adminAccessToken);
     $this->assertEquals($res['statusCode'], 401);
     $this->assertEquals($res['data']['error'], 'permission failure');
     $res = ApiControllerTest::send_test('GET', 'auth/testSendError', $data = null, $adminAccessToken);
     $this->assertEquals($res['statusCode'], 500);
     $this->assertEquals($res['data']['error'], 'unspecified error');
     $res = ApiControllerTest::send_test('PUT', 'auth/testSuccessfulPut', $data = null, $adminAccessToken);
     $this->assertEquals($res['statusCode'], 201);
     $this->assertEquals($res['data']['message'], 'resource updated successfully');
     $res = ApiControllerTest::send_test('DELETE', 'auth/testSendSuccessfulDelete', $data = null, $adminAccessToken);
     $this->assertEquals($res['statusCode'], 202);
     $this->assertEquals($res['data']['message'], 'resource deleted successfully');
     $res = ApiControllerTest::send_test('POST', 'auth/testSendSuccessfulPost', $data = null, $adminAccessToken);
     $this->assertEquals($res['statusCode'], 201);
     $this->assertEquals($res['data']['message'], 'resource created succesfully');
     $res = ApiControllerTest::send_test('GET', 'auth/testSendNotFound', $data = null, $adminAccessToken);
     $this->assertEquals($res['statusCode'], 404);
     $this->assertEquals($res['data']['message'], 'resource not found');
     $res = ApiControllerTest::send_test('GET', 'auth/testWrongMethodName', $data = null, $adminAccessToken, $expectJSON);
     $this->assertEquals($res['statusCode'], 404);
     $this->assertEquals($res['body'], "Action 'testWrongMethodName' isn't available on class AuthController.");
     $res = ApiControllerTest::send_test('GET', 'auth/testSendingEmptyData', $data = null, $adminAccessToken, $expectJSON);
     $this->assertEquals($res['statusCode'], 404);
 }