Fixed oauth2 analysis warnings
This commit is contained in:
parent
3fe1778c27
commit
45218176c7
6 changed files with 9 additions and 11 deletions
|
@ -6,7 +6,7 @@ import 'package:angel3_oauth2/angel3_oauth2.dart';
|
|||
void main() async {
|
||||
var app = Angel();
|
||||
var oauth2 = _ExampleAuthorizationServer();
|
||||
var _rgxBearer = RegExp(r'^[Bb]earer ([^\n\s]+)$');
|
||||
var rgxBearer = RegExp(r'^[Bb]earer ([^\n\s]+)$');
|
||||
|
||||
app.group('/auth', (router) {
|
||||
router
|
||||
|
@ -17,7 +17,7 @@ void main() async {
|
|||
// Assume that all other requests must be authenticated...
|
||||
app.fallback((req, res) {
|
||||
var authToken =
|
||||
req.headers!.value('authorization')?.replaceAll(_rgxBearer, '').trim();
|
||||
req.headers!.value('authorization')?.replaceAll(rgxBearer, '').trim();
|
||||
|
||||
if (authToken == null) {
|
||||
throw AngelHttpException.forbidden();
|
||||
|
|
|
@ -234,7 +234,7 @@ abstract class AuthorizationServer<Client, User> {
|
|||
if (buf.isNotEmpty) buf.write('&');
|
||||
return buf
|
||||
..write(
|
||||
'$k=' + Uri.encodeComponent(queryParameters[k]!),
|
||||
'$k=${Uri.encodeComponent(queryParameters[k]!)}',
|
||||
);
|
||||
}).toString();
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ void main() {
|
|||
|
||||
var authCode = json.decode(response.body)['code'].toString();
|
||||
var client = await grant.handleAuthorizationCode(authCode);
|
||||
expect(client.credentials.accessToken, authCode + '_access');
|
||||
expect(client.credentials.accessToken, '${authCode}_access');
|
||||
});
|
||||
|
||||
test('can send refresh token', () async {
|
||||
|
@ -111,9 +111,9 @@ void main() {
|
|||
|
||||
var authCode = json.decode(response.body)['code'].toString();
|
||||
var client = await grant.handleAuthorizationCode(authCode);
|
||||
expect(client.credentials.accessToken, authCode + '_access');
|
||||
expect(client.credentials.accessToken, '${authCode}_access');
|
||||
expect(client.credentials.canRefresh, isTrue);
|
||||
expect(client.credentials.refreshToken, authCode + '_refresh');
|
||||
expect(client.credentials.refreshToken, '${authCode}_refresh');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ void main() {
|
|||
var response = await client.post(
|
||||
Uri.parse('oauth2/token'),
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + base64Url.encode('foo:bar'.codeUnits),
|
||||
'Authorization': 'Basic ${base64Url.encode('foo:bar'.codeUnits)}',
|
||||
},
|
||||
body: {
|
||||
'grant_type': 'client_credentials',
|
||||
|
@ -60,7 +60,7 @@ void main() {
|
|||
var response = await client.post(
|
||||
Uri.parse('/oauth2/token'),
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + base64Url.encode('fooa:bar'.codeUnits),
|
||||
'Authorization': 'Basic ${base64Url.encode('fooa:bar'.codeUnits)}',
|
||||
},
|
||||
body: {
|
||||
'grant_type': 'client_credentials',
|
||||
|
@ -75,7 +75,7 @@ void main() {
|
|||
var response = await client.post(
|
||||
Uri.parse('/oauth2/token'),
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + base64Url.encode('foo:bara'.codeUnits),
|
||||
'Authorization': 'Basic ${base64Url.encode('foo:bara'.codeUnits)}',
|
||||
},
|
||||
body: {
|
||||
'grant_type': 'client_credentials',
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:async';
|
|||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_test/angel3_test.dart';
|
||||
import 'package:angel3_oauth2/angel3_oauth2.dart';
|
||||
import 'package:angel3_validate/angel3_validate.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'common.dart';
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:async';
|
|||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_test/angel3_test.dart';
|
||||
import 'package:angel3_oauth2/angel3_oauth2.dart';
|
||||
import 'package:angel3_validate/angel3_validate.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'common.dart';
|
||||
|
||||
|
|
Loading…
Reference in a new issue