feat: strava deeplink to mobile
This commit is contained in:
@@ -10,13 +10,13 @@ use Laravel\Sanctum\Sanctum;
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
config()->set('app.url', 'https://bemeal.leonmorival.com');
|
||||
config()->set('services.strava.client_id', '248440');
|
||||
config()->set('services.strava.client_secret', 'strava-secret');
|
||||
config()->set('services.strava.redirect_uri', 'dailymeal://strava/callback');
|
||||
config()->set('services.strava.scope', 'read,activity:read');
|
||||
});
|
||||
|
||||
it('returns a strava authorization url for the mobile app', function () {
|
||||
it('returns a strava authorization url for the api callback', function () {
|
||||
Sanctum::actingAs(User::factory()->create());
|
||||
|
||||
$response = $this->getJson('/api/strava/authorization-url');
|
||||
@@ -30,13 +30,25 @@ it('returns a strava authorization url for the mobile app', function () {
|
||||
parse_str((string) parse_url($authorizationUrl, PHP_URL_QUERY), $query);
|
||||
|
||||
expect($query['client_id'])->toBe('248440');
|
||||
expect($query['redirect_uri'])->toBe('dailymeal://strava/callback');
|
||||
expect($query['redirect_uri'])->toBe('https://bemeal.leonmorival.com/strava/callback');
|
||||
expect($query['response_type'])->toBe('code');
|
||||
expect($query['approval_prompt'])->toBe('auto');
|
||||
expect($query['scope'])->toBe('read,activity:read');
|
||||
expect($query['state'])->not->toBeEmpty();
|
||||
});
|
||||
|
||||
it('redirects the strava web callback to the mobile app', function () {
|
||||
$query = http_build_query([
|
||||
'code' => 'authorization-code',
|
||||
'scope' => 'read activity:read',
|
||||
'state' => 'oauth-state',
|
||||
], '', '&', PHP_QUERY_RFC3986);
|
||||
|
||||
$this
|
||||
->get("/strava/callback?{$query}")
|
||||
->assertRedirect("dailymeal://strava/callback?{$query}");
|
||||
});
|
||||
|
||||
it('stores strava tokens from an authorization code', function () {
|
||||
Http::preventStrayRequests();
|
||||
Http::fake([
|
||||
|
||||
Reference in New Issue
Block a user