Skip to content

Commit

Permalink
test: refactor to oauth2 package
Browse files Browse the repository at this point in the history
  • Loading branch information
tnc1997 committed May 20, 2021
1 parent 7a32afa commit a574314
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions test/apetito_product_api_client_test.dart
@@ -1,5 +1,6 @@
import 'package:apetito_product_api_client/apetito_product_api_client.dart';
import 'package:http/http.dart';
import 'package:oauth2/oauth2.dart' as oauth2;
import 'package:test/test.dart';

void main() {
Expand Down Expand Up @@ -886,8 +887,13 @@ void main() {
);

setUpAll(
() {
client = _AuthenticatedClient();
() async {
client = await oauth2.clientCredentialsGrant(
Uri.https('identity.apetito.co.uk', '/connect/token'),
'identifier',
'secret',
scopes: ['Products.Read.All'],
);
},
);

Expand All @@ -897,17 +903,3 @@ void main() {
},
);
}

class _AuthenticatedClient extends BaseClient {
@override
Future<StreamedResponse> send(BaseRequest request) {
final _ = Request(
request.method,
request.url,
);

_.headers['Authorization'] = 'Bearer ACCESS_TOKEN';

return _.send();
}
}

0 comments on commit a574314

Please sign in to comment.