Merge branch 'dev'
This commit is contained in:
commit
18b1b00f45
@ -1,30 +1,30 @@
|
||||
// This is a basic Flutter widget test.
|
||||
//
|
||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||
// utility in the flutter_test package. For example, you can send tap and scroll
|
||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// tree, read text, and verify that the values of widget properties are correct.
|
||||
// // This is a basic Flutter widget test.
|
||||
// //
|
||||
// // To perform an interaction with a widget in your test, use the WidgetTester
|
||||
// // utility in the flutter_test package. For example, you can send tap and scroll
|
||||
// // gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// // tree, read text, and verify that the values of widget properties are correct.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:filcnaplo/main.dart';
|
||||
// import 'package:filcnaplo/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MyApp());
|
||||
// void main() {
|
||||
// testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// // Build our app and trigger a frame.
|
||||
// await tester.pumpWidget(const MyApp());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
expect(find.text('1'), findsNothing);
|
||||
// // Verify that our counter starts at 0.
|
||||
// expect(find.text('0'), findsOneWidget);
|
||||
// expect(find.text('1'), findsNothing);
|
||||
|
||||
// Tap the '+' icon and trigger a frame.
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
await tester.pump();
|
||||
// // Tap the '+' icon and trigger a frame.
|
||||
// await tester.tap(find.byIcon(Icons.add));
|
||||
// await tester.pump();
|
||||
|
||||
// Verify that our counter has incremented.
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
// // Verify that our counter has incremented.
|
||||
// expect(find.text('0'), findsNothing);
|
||||
// expect(find.text('1'), findsOneWidget);
|
||||
// });
|
||||
// }
|
||||
|
@ -66,8 +66,10 @@ class KretaClient {
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (autoHeader) {
|
||||
if (!headerMap.containsKey("authorization") && accessToken != null) headerMap["authorization"] = "Bearer $accessToken";
|
||||
if (!headerMap.containsKey("user-agent") && userAgent != null) headerMap["user-agent"] = "$userAgent";
|
||||
if (!headerMap.containsKey("authorization") && accessToken != null)
|
||||
headerMap["authorization"] = "Bearer $accessToken";
|
||||
if (!headerMap.containsKey("user-agent") && userAgent != null)
|
||||
headerMap["user-agent"] = "$userAgent";
|
||||
}
|
||||
|
||||
res = await client.get(Uri.parse(url), headers: headerMap);
|
||||
@ -94,7 +96,8 @@ class KretaClient {
|
||||
return res.body;
|
||||
}
|
||||
} on http.ClientException catch (error) {
|
||||
print("ERROR: KretaClient.getAPI ($url) ClientException: ${error.message}");
|
||||
print(
|
||||
"ERROR: KretaClient.getAPI ($url) ClientException: ${error.message}");
|
||||
} catch (error) {
|
||||
print("ERROR: KretaClient.getAPI ($url) ${error.runtimeType}: $error");
|
||||
}
|
||||
@ -120,9 +123,12 @@ class KretaClient {
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (autoHeader) {
|
||||
if (!headerMap.containsKey("authorization") && accessToken != null) headerMap["authorization"] = "Bearer $accessToken";
|
||||
if (!headerMap.containsKey("user-agent") && userAgent != null) headerMap["user-agent"] = "$userAgent";
|
||||
if (!headerMap.containsKey("content-type")) headerMap["content-type"] = "application/json";
|
||||
if (!headerMap.containsKey("authorization") && accessToken != null)
|
||||
headerMap["authorization"] = "Bearer $accessToken";
|
||||
if (!headerMap.containsKey("user-agent") && userAgent != null)
|
||||
headerMap["user-agent"] = "$userAgent";
|
||||
if (!headerMap.containsKey("content-type"))
|
||||
headerMap["content-type"] = "application/json";
|
||||
}
|
||||
|
||||
res = await client.post(Uri.parse(url), headers: headerMap, body: body);
|
||||
@ -142,9 +148,10 @@ class KretaClient {
|
||||
return res.body;
|
||||
}
|
||||
} on http.ClientException catch (error) {
|
||||
print("ERROR: KretaClient.getAPI ($url) ClientException: ${error.message}");
|
||||
print(
|
||||
"ERROR: KretaClient.postAPI ($url) ClientException: ${error.message}");
|
||||
} catch (error) {
|
||||
print("ERROR: KretaClient.getAPI ($url) ${error.runtimeType}: $error");
|
||||
print("ERROR: KretaClient.postAPI ($url) ${error.runtimeType}: $error");
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +164,8 @@ class KretaClient {
|
||||
};
|
||||
|
||||
String nonceStr = await getAPI(KretaAPI.nonce, json: false);
|
||||
Nonce nonce = getNonce(nonceStr, loginUser.username, loginUser.instituteCode);
|
||||
Nonce nonce =
|
||||
getNonce(nonceStr, loginUser.username, loginUser.instituteCode);
|
||||
headers.addAll(nonce.header());
|
||||
|
||||
if (_settings.presentationMode) {
|
||||
@ -175,18 +183,25 @@ class KretaClient {
|
||||
));
|
||||
|
||||
if (loginRes != null) {
|
||||
if (loginRes.containsKey("access_token")) accessToken = loginRes["access_token"];
|
||||
if (loginRes.containsKey("refresh_token")) refreshToken = loginRes["refresh_token"];
|
||||
if (loginRes.containsKey("access_token"))
|
||||
accessToken = loginRes["access_token"];
|
||||
if (loginRes.containsKey("refresh_token"))
|
||||
refreshToken = loginRes["refresh_token"];
|
||||
|
||||
// Update role
|
||||
loginUser.role = JwtUtils.getRoleFromJWT(accessToken ?? "") ?? Role.student;
|
||||
loginUser.role =
|
||||
JwtUtils.getRoleFromJWT(accessToken ?? "") ?? Role.student;
|
||||
}
|
||||
|
||||
if (refreshToken != null) {
|
||||
Map? refreshRes = await postAPI(KretaAPI.login,
|
||||
headers: headers, body: User.refreshBody(refreshToken: refreshToken!, instituteCode: loginUser.instituteCode));
|
||||
headers: headers,
|
||||
body: User.refreshBody(
|
||||
refreshToken: refreshToken!,
|
||||
instituteCode: loginUser.instituteCode));
|
||||
if (refreshRes != null) {
|
||||
if (refreshRes.containsKey("id_token")) idToken = refreshRes["id_token"];
|
||||
if (refreshRes.containsKey("id_token"))
|
||||
idToken = refreshRes["id_token"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user