summaryrefslogtreecommitdiff
path: root/tests/units/Auth
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-29 20:15:53 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-29 20:15:53 -0500
commitdae0c7391ab8308506bddc5fff76414a3bb87ce4 (patch)
tree1b594635ceee536c986b8f4f24a7122858ab7fc3 /tests/units/Auth
parent915bf5882293d7041e8e5d0f5c32b8acf0938148 (diff)
Move Google authentication to an external plugin
Diffstat (limited to 'tests/units/Auth')
-rw-r--r--tests/units/Auth/GoogleAuthTest.php89
1 files changed, 0 insertions, 89 deletions
diff --git a/tests/units/Auth/GoogleAuthTest.php b/tests/units/Auth/GoogleAuthTest.php
deleted file mode 100644
index b9a7d811..00000000
--- a/tests/units/Auth/GoogleAuthTest.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-
-require_once __DIR__.'/../Base.php';
-
-use Kanboard\Auth\GoogleAuth;
-use Kanboard\Model\User;
-
-class GoogleAuthTest extends Base
-{
- public function testGetName()
- {
- $provider = new GoogleAuth($this->container);
- $this->assertEquals('Google', $provider->getName());
- }
-
- public function testAuthenticationSuccessful()
- {
- $profile = array(
- 'id' => 1234,
- 'email' => 'test@localhost',
- 'name' => 'Test',
- );
-
- $provider = $this
- ->getMockBuilder('\Kanboard\Auth\GoogleAuth')
- ->setConstructorArgs(array($this->container))
- ->setMethods(array(
- 'getProfile',
- ))
- ->getMock();
-
- $provider->expects($this->once())
- ->method('getProfile')
- ->will($this->returnValue($profile));
-
- $this->assertInstanceOf('Kanboard\Auth\GoogleAuth', $provider->setCode('1234'));
-
- $this->assertTrue($provider->authenticate());
-
- $user = $provider->getUser();
- $this->assertInstanceOf('Kanboard\User\GoogleUserProvider', $user);
- $this->assertEquals('Test', $user->getName());
- $this->assertEquals('', $user->getInternalId());
- $this->assertEquals(1234, $user->getExternalId());
- $this->assertEquals('', $user->getRole());
- $this->assertEquals('', $user->getUsername());
- $this->assertEquals('test@localhost', $user->getEmail());
- $this->assertEquals('google_id', $user->getExternalIdColumn());
- $this->assertEquals(array(), $user->getExternalGroupIds());
- $this->assertEquals(array(), $user->getExtraAttributes());
- $this->assertFalse($user->isUserCreationAllowed());
- }
-
- public function testAuthenticationFailed()
- {
- $provider = $this
- ->getMockBuilder('\Kanboard\Auth\GoogleAuth')
- ->setConstructorArgs(array($this->container))
- ->setMethods(array(
- 'getProfile',
- ))
- ->getMock();
-
- $provider->expects($this->once())
- ->method('getProfile')
- ->will($this->returnValue(array()));
-
- $this->assertFalse($provider->authenticate());
- $this->assertEquals(null, $provider->getUser());
- }
-
- public function testGetService()
- {
- $provider = new GoogleAuth($this->container);
- $this->assertInstanceOf('Kanboard\Core\Http\OAuth2', $provider->getService());
- }
-
- public function testUnlink()
- {
- $userModel = new User($this->container);
- $provider = new GoogleAuth($this->container);
-
- $this->assertEquals(2, $userModel->create(array('username' => 'test', 'google_id' => '1234')));
- $this->assertNotEmpty($userModel->getByExternalId('google_id', 1234));
-
- $this->assertTrue($provider->unlink(2));
- $this->assertEmpty($userModel->getByExternalId('google_id', 1234));
- }
-}