diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-29 23:59:58 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-29 23:59:58 -0500 |
commit | 9b9d823f30f7f7744f412df8ca4c52d7be3c9977 (patch) | |
tree | 50a21284bf17246206c102153ff60a890888d4f2 /tests | |
parent | 04d8c6532c441c4ba4699020374ffab85685082d (diff) |
Move Gitlab and Github authentication to external plugins
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Auth/GithubAuthTest.php | 89 | ||||
-rw-r--r-- | tests/units/Auth/GitlabAuthTest.php | 89 | ||||
-rw-r--r-- | tests/units/Base.php | 2 |
3 files changed, 2 insertions, 178 deletions
diff --git a/tests/units/Auth/GithubAuthTest.php b/tests/units/Auth/GithubAuthTest.php deleted file mode 100644 index e9ab066f..00000000 --- a/tests/units/Auth/GithubAuthTest.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -require_once __DIR__.'/../Base.php'; - -use Kanboard\Auth\GithubAuth; -use Kanboard\Model\User; - -class GithubAuthTest extends Base -{ - public function testGetName() - { - $provider = new GithubAuth($this->container); - $this->assertEquals('Github', $provider->getName()); - } - - public function testAuthenticationSuccessful() - { - $profile = array( - 'id' => 1234, - 'email' => 'test@localhost', - 'name' => 'Test', - ); - - $provider = $this - ->getMockBuilder('\Kanboard\Auth\GithubAuth') - ->setConstructorArgs(array($this->container)) - ->setMethods(array( - 'getProfile', - )) - ->getMock(); - - $provider->expects($this->once()) - ->method('getProfile') - ->will($this->returnValue($profile)); - - $this->assertInstanceOf('Kanboard\Auth\GithubAuth', $provider->setCode('1234')); - - $this->assertTrue($provider->authenticate()); - - $user = $provider->getUser(); - $this->assertInstanceOf('Kanboard\User\GithubUserProvider', $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('github_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\GithubAuth') - ->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 GithubAuth($this->container); - $this->assertInstanceOf('Kanboard\Core\Http\OAuth2', $provider->getService()); - } - - public function testUnlink() - { - $userModel = new User($this->container); - $provider = new GithubAuth($this->container); - - $this->assertEquals(2, $userModel->create(array('username' => 'test', 'github_id' => '1234'))); - $this->assertNotEmpty($userModel->getByExternalId('github_id', 1234)); - - $this->assertTrue($provider->unlink(2)); - $this->assertEmpty($userModel->getByExternalId('github_id', 1234)); - } -} diff --git a/tests/units/Auth/GitlabAuthTest.php b/tests/units/Auth/GitlabAuthTest.php deleted file mode 100644 index e3ae0bdd..00000000 --- a/tests/units/Auth/GitlabAuthTest.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -require_once __DIR__.'/../Base.php'; - -use Kanboard\Auth\GitlabAuth; -use Kanboard\Model\User; - -class GitlabAuthTest extends Base -{ - public function testGetName() - { - $provider = new GitlabAuth($this->container); - $this->assertEquals('Gitlab', $provider->getName()); - } - - public function testAuthenticationSuccessful() - { - $profile = array( - 'id' => 1234, - 'email' => 'test@localhost', - 'name' => 'Test', - ); - - $provider = $this - ->getMockBuilder('\Kanboard\Auth\GitlabAuth') - ->setConstructorArgs(array($this->container)) - ->setMethods(array( - 'getProfile', - )) - ->getMock(); - - $provider->expects($this->once()) - ->method('getProfile') - ->will($this->returnValue($profile)); - - $this->assertInstanceOf('Kanboard\Auth\GitlabAuth', $provider->setCode('1234')); - - $this->assertTrue($provider->authenticate()); - - $user = $provider->getUser(); - $this->assertInstanceOf('Kanboard\User\GitlabUserProvider', $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('gitlab_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\GitlabAuth') - ->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 GitlabAuth($this->container); - $this->assertInstanceOf('Kanboard\Core\Http\OAuth2', $provider->getService()); - } - - public function testUnlink() - { - $userModel = new User($this->container); - $provider = new GitlabAuth($this->container); - - $this->assertEquals(2, $userModel->create(array('username' => 'test', 'gitlab_id' => '1234'))); - $this->assertNotEmpty($userModel->getByExternalId('gitlab_id', 1234)); - - $this->assertTrue($provider->unlink(2)); - $this->assertEmpty($userModel->getByExternalId('gitlab_id', 1234)); - } -} diff --git a/tests/units/Base.php b/tests/units/Base.php index 7ac83289..1eb9a9df 100644 --- a/tests/units/Base.php +++ b/tests/units/Base.php @@ -10,6 +10,7 @@ use SimpleLogger\Logger; use SimpleLogger\File; use Kanboard\Core\Session\FlashMessage; use Kanboard\Core\Session\SessionStorage; +use Kanboard\Core\Action\ActionManager; class FakeHttpClient { @@ -104,6 +105,7 @@ abstract class Base extends PHPUnit_Framework_TestCase ->getMock(); $this->container['sessionStorage'] = new SessionStorage; + $this->container['actionManager'] = new ActionManager($this->container); $this->container['flash'] = function($c) { return new FlashMessage($c); |