예제 #1
0
 /**
  * Test login E2E via HTTP entry point
  *
  *
  */
 public function testNativeLoginPositiveViaHttp()
 {
     // Create an user
     $user = UserFactory::createUser();
     // Set required context
     $_REQUEST['usernameOrEmail'] = $user->getUsername();
     $_REQUEST['password'] = $user->getPassword();
     // Turn on flag to return auth_token in response, just to validate it
     $_REQUEST['returnAuthToken'] = true;
     // Override session_start, phpunit doesn't like it, but we still validate that it is called once
     $this->mockSessionManager();
     // Call api
     $_SERVER['REQUEST_URI'] = '/api/user/login';
     $response = json_decode(ApiCallerMock::httpEntryPoint(), true);
     // Validate output
     $this->assertEquals('ok', $response['status']);
     $this->assertLogin($user, $response['auth_token']);
 }
예제 #2
0
 /**
  * Tests Create User API happy path excercising the httpEntryPoint
  */
 public function testCreateUserPositiveViahttpEntryPoint()
 {
     UserController::$permissionKey = uniqid();
     // Set context
     $_REQUEST['username'] = Utils::CreateRandomString();
     $_REQUEST['password'] = Utils::CreateRandomString();
     $_REQUEST['email'] = Utils::CreateRandomString() . '@' . Utils::CreateRandomString() . '.com';
     $_REQUEST['permission_key'] = UserController::$permissionKey;
     // Override session_start, phpunit doesn't like it, but we still validate that it is called once
     $this->mockSessionManager();
     // Call api
     $_SERVER['REQUEST_URI'] = '/api/user/create';
     $response = json_decode(ApiCallerMock::httpEntryPoint(), true);
     $this->assertEquals('ok', $response['status']);
     // Verify DB
     $user = UsersDAO::FindByUsername($_REQUEST['username']);
     $this->assertNotNull($user);
 }
예제 #3
0
 /**
  * Tests Create User API happy path excercising the httpEntryPoint
  */
 public function testCreateUserPositiveViahttpEntryPoint()
 {
     UserController::$permissionKey = uniqid();
     // Set context
     $_REQUEST["username"] = Utils::CreateRandomString();
     $_REQUEST["password"] = Utils::CreateRandomString();
     $_REQUEST["email"] = Utils::CreateRandomString() . "@" . Utils::CreateRandomString() . ".com";
     $_REQUEST["permission_key"] = UserController::$permissionKey;
     // Override session_start, phpunit doesn't like it, but we still validate that it is called once
     $this->mockSessionManager();
     // Call api
     $_SERVER["REQUEST_URI"] = "/api/user/create";
     $response = json_decode(ApiCallerMock::httpEntryPoint(), true);
     $this->assertEquals("ok", $response["status"]);
     // Verify DB
     $user = UsersDAO::FindByUsername($_REQUEST["username"]);
     $this->assertNotNull($user);
 }