Merge pull request #106 from ssddanbrown/ci_testing
Ci testing
Showing
6 changed files
with
18 additions
and
9 deletions
| ... | @@ -34,6 +34,17 @@ class Ldap | ... | @@ -34,6 +34,17 @@ class Ldap |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | + * Set the version number for the given ldap connection. | ||
| 38 | + * @param $ldapConnection | ||
| 39 | + * @param $version | ||
| 40 | + * @return bool | ||
| 41 | + */ | ||
| 42 | + public function setVersion($ldapConnection, $version) | ||
| 43 | + { | ||
| 44 | + return $this->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $version); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 37 | * Search LDAP tree using the provided filter. | 48 | * Search LDAP tree using the provided filter. |
| 38 | * @param resource $ldapConnection | 49 | * @param resource $ldapConnection |
| 39 | * @param string $baseDn | 50 | * @param string $baseDn | ... | ... |
| ... | @@ -122,7 +122,7 @@ class LdapService | ... | @@ -122,7 +122,7 @@ class LdapService |
| 122 | 122 | ||
| 123 | // Set any required options | 123 | // Set any required options |
| 124 | if ($this->config['version']) { | 124 | if ($this->config['version']) { |
| 125 | - $this->ldap->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $this->config['version']); | 125 | + $this->ldap->setVersion($ldapConnection, $this->config['version']); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | $this->ldapConnection = $ldapConnection; | 128 | $this->ldapConnection = $ldapConnection; | ... | ... |
| 1 | <?php namespace BookStack\Services; | 1 | <?php namespace BookStack\Services; |
| 2 | 2 | ||
| 3 | -use GuzzleHttp\Exception\ClientException; | ||
| 4 | use Laravel\Socialite\Contracts\Factory as Socialite; | 3 | use Laravel\Socialite\Contracts\Factory as Socialite; |
| 5 | use BookStack\Exceptions\SocialDriverNotConfigured; | 4 | use BookStack\Exceptions\SocialDriverNotConfigured; |
| 6 | use BookStack\Exceptions\SocialSignInException; | 5 | use BookStack\Exceptions\SocialSignInException; |
| 7 | use BookStack\Exceptions\UserRegistrationException; | 6 | use BookStack\Exceptions\UserRegistrationException; |
| 8 | -use BookStack\Http\Controllers\Auth\AuthController; | ||
| 9 | use BookStack\Repos\UserRepo; | 7 | use BookStack\Repos\UserRepo; |
| 10 | use BookStack\SocialAccount; | 8 | use BookStack\SocialAccount; |
| 11 | -use BookStack\User; | ||
| 12 | 9 | ||
| 13 | class SocialAuthService | 10 | class SocialAuthService |
| 14 | { | 11 | { | ... | ... |
| ... | @@ -84,8 +84,8 @@ return [ | ... | @@ -84,8 +84,8 @@ return [ |
| 84 | 'driver' => 'mysql', | 84 | 'driver' => 'mysql', |
| 85 | 'host' => 'localhost', | 85 | 'host' => 'localhost', |
| 86 | 'database' => 'bookstack-test', | 86 | 'database' => 'bookstack-test', |
| 87 | - 'username' => 'bookstack-test', | 87 | + 'username' => env('MYSQL_USER', 'bookstack-test'), |
| 88 | - 'password' => 'bookstack-test', | 88 | + 'password' => env('MYSQL_PASSWORD', 'bookstack-test'), |
| 89 | 'charset' => 'utf8', | 89 | 'charset' => 'utf8', |
| 90 | 'collation' => 'utf8_unicode_ci', | 90 | 'collation' => 'utf8_unicode_ci', |
| 91 | 'prefix' => '', | 91 | 'prefix' => '', | ... | ... |
| ... | @@ -34,5 +34,6 @@ | ... | @@ -34,5 +34,6 @@ |
| 34 | <env name="GITHUB_APP_SECRET" value="aaaaaaaaaaaaaa"/> | 34 | <env name="GITHUB_APP_SECRET" value="aaaaaaaaaaaaaa"/> |
| 35 | <env name="GOOGLE_APP_ID" value="aaaaaaaaaaaaaa"/> | 35 | <env name="GOOGLE_APP_ID" value="aaaaaaaaaaaaaa"/> |
| 36 | <env name="GOOGLE_APP_SECRET" value="aaaaaaaaaaaaaa"/> | 36 | <env name="GOOGLE_APP_SECRET" value="aaaaaaaaaaaaaa"/> |
| 37 | + <env name="APP_URL" value="http://bookstack.dev"/> | ||
| 37 | </php> | 38 | </php> |
| 38 | </phpunit> | 39 | </phpunit> | ... | ... |
| ... | @@ -22,7 +22,7 @@ class LdapTest extends \TestCase | ... | @@ -22,7 +22,7 @@ class LdapTest extends \TestCase |
| 22 | public function test_login() | 22 | public function test_login() |
| 23 | { | 23 | { |
| 24 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); | 24 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); |
| 25 | - $this->mockLdap->shouldReceive('setOption')->once(); | 25 | + $this->mockLdap->shouldReceive('setVersion')->once(); |
| 26 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(4) | 26 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(4) |
| 27 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) | 27 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) |
| 28 | ->andReturn(['count' => 1, 0 => [ | 28 | ->andReturn(['count' => 1, 0 => [ |
| ... | @@ -49,7 +49,7 @@ class LdapTest extends \TestCase | ... | @@ -49,7 +49,7 @@ class LdapTest extends \TestCase |
| 49 | public function test_login_works_when_no_uid_provided_by_ldap_server() | 49 | public function test_login_works_when_no_uid_provided_by_ldap_server() |
| 50 | { | 50 | { |
| 51 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); | 51 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); |
| 52 | - $this->mockLdap->shouldReceive('setOption')->once(); | 52 | + $this->mockLdap->shouldReceive('setVersion')->once(); |
| 53 | $ldapDn = 'cn=test-user,dc=test' . config('services.ldap.base_dn'); | 53 | $ldapDn = 'cn=test-user,dc=test' . config('services.ldap.base_dn'); |
| 54 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2) | 54 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2) |
| 55 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) | 55 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) |
| ... | @@ -73,7 +73,7 @@ class LdapTest extends \TestCase | ... | @@ -73,7 +73,7 @@ class LdapTest extends \TestCase |
| 73 | public function test_initial_incorrect_details() | 73 | public function test_initial_incorrect_details() |
| 74 | { | 74 | { |
| 75 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); | 75 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); |
| 76 | - $this->mockLdap->shouldReceive('setOption')->once(); | 76 | + $this->mockLdap->shouldReceive('setVersion')->once(); |
| 77 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2) | 77 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2) |
| 78 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) | 78 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) |
| 79 | ->andReturn(['count' => 1, 0 => [ | 79 | ->andReturn(['count' => 1, 0 => [ | ... | ... |
-
Please register or sign in to post a comment