|
3 | 3 | namespace Laravel\Socialite\Tests;
|
4 | 4 |
|
5 | 5 | use Laravel\Socialite\Contracts\Factory;
|
| 6 | +use Laravel\Socialite\Exceptions\DriverMissingConfigurationException; |
6 | 7 | use Laravel\Socialite\SocialiteServiceProvider;
|
7 | 8 | use Laravel\Socialite\Two\GithubProvider;
|
8 | 9 | use Orchestra\Testbench\TestCase;
|
@@ -77,4 +78,61 @@ public function test_it_can_instantiate_the_github_driver_with_scopes_from_confi
|
77 | 78 | $provider = $factory->driver('github')->setScopes(['read:user']);
|
78 | 79 | $this->assertSame(['read:user'], $provider->getScopes());
|
79 | 80 | }
|
| 81 | + |
| 82 | + public function test_it_throws_exception_when_client_secret_is_missing() |
| 83 | + { |
| 84 | + $this->expectException(DriverMissingConfigurationException::class); |
| 85 | + $this->expectExceptionMessage('Missing required configuration keys [client_secret] for [Laravel\Socialite\Two\GithubProvider] OAuth provider.'); |
| 86 | + |
| 87 | + $factory = $this->app->make(Factory::class); |
| 88 | + |
| 89 | + $this->app['config']->set('services.github', [ |
| 90 | + 'client_id' => 'github-client-id', |
| 91 | + 'redirect' => 'http://your-callback-url', |
| 92 | + ]); |
| 93 | + |
| 94 | + $factory->driver('github'); |
| 95 | + } |
| 96 | + |
| 97 | + public function test_it_throws_exception_when_client_id_is_missing() |
| 98 | + { |
| 99 | + $this->expectException(DriverMissingConfigurationException::class); |
| 100 | + $this->expectExceptionMessage('Missing required configuration keys [client_id] for [Laravel\Socialite\Two\GithubProvider] OAuth provider.'); |
| 101 | + |
| 102 | + $factory = $this->app->make(Factory::class); |
| 103 | + |
| 104 | + $this->app['config']->set('services.github', [ |
| 105 | + 'client_secret' => 'github-client-secret', |
| 106 | + 'redirect' => 'http://your-callback-url', |
| 107 | + ]); |
| 108 | + |
| 109 | + $factory->driver('github'); |
| 110 | + } |
| 111 | + |
| 112 | + public function test_it_throws_exception_when_redirect_is_missing() |
| 113 | + { |
| 114 | + $this->expectException(DriverMissingConfigurationException::class); |
| 115 | + $this->expectExceptionMessage('Missing required configuration keys [redirect] for [Laravel\Socialite\Two\GithubProvider] OAuth provider.'); |
| 116 | + |
| 117 | + $factory = $this->app->make(Factory::class); |
| 118 | + |
| 119 | + $this->app['config']->set('services.github', [ |
| 120 | + 'client_id' => 'github-client-id', |
| 121 | + 'client_secret' => 'github-client-secret', |
| 122 | + ]); |
| 123 | + |
| 124 | + $factory->driver('github'); |
| 125 | + } |
| 126 | + |
| 127 | + public function test_it_throws_exception_when_configuration_is_completely_missing() |
| 128 | + { |
| 129 | + $this->expectException(DriverMissingConfigurationException::class); |
| 130 | + $this->expectExceptionMessage('Missing required configuration keys [client_id, client_secret, redirect] for [Laravel\Socialite\Two\GithubProvider] OAuth provider.'); |
| 131 | + |
| 132 | + $factory = $this->app->make(Factory::class); |
| 133 | + |
| 134 | + $this->app['config']->set('services.github', null); |
| 135 | + |
| 136 | + $factory->driver('github'); |
| 137 | + } |
80 | 138 | }
|
0 commit comments