test 2
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
import 'dart:convert';
|
||||
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
||||
import 'package:fbla_api/fbla_api.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:io';
|
||||
|
||||
final apiAddress = 'https://homelab.marinodev.com';
|
||||
SecretKey secretKey = SecretKey(Platform.environment['SECRET_KEY']!);
|
||||
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
||||
import 'package:fbla_api/fbla_api.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() async{
|
||||
final apiAddress = 'https://homelab.marinodev.com';
|
||||
SecretKey secretKey = SecretKey(Platform.environment['JOBLINK_SECRET_KEY']!);
|
||||
|
||||
void main() async {
|
||||
final jwt = JWT(
|
||||
{
|
||||
'username': 'tmp'
|
||||
},
|
||||
{'username': 'tmp'},
|
||||
);
|
||||
final token = jwt.sign(secretKey);
|
||||
|
||||
@@ -43,13 +42,14 @@ void main() async{
|
||||
"password": "tmp"
|
||||
}
|
||||
''';
|
||||
var response = await http.post(Uri.parse('$apiAddress, /fbla-api/createuser'),
|
||||
var response = await http.post(
|
||||
Uri.parse('$apiAddress, /fbla-api/createuser'),
|
||||
body: json,
|
||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
||||
expect(response.statusCode, 200);
|
||||
expect(response.body, 'tmp');
|
||||
});
|
||||
test('sign-in', () async{
|
||||
test('sign-in', () async {
|
||||
var json = '''
|
||||
{
|
||||
"username": "tmp",
|
||||
@@ -64,17 +64,15 @@ void main() async{
|
||||
expect(response.statusCode, 200);
|
||||
expect(JWT.decode(response.body).payload['username'], 'tmp');
|
||||
});
|
||||
test('delete-user', () async{
|
||||
test('delete-user', () async {
|
||||
var json = '''
|
||||
{
|
||||
"username": "tmp"
|
||||
}
|
||||
''';
|
||||
var response = await http.post(
|
||||
Uri.parse('$apiAddress/fbla-api/deleteuser'),
|
||||
var response = await http.post(Uri.parse('$apiAddress/fbla-api/deleteuser'),
|
||||
body: json,
|
||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20)
|
||||
);
|
||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
||||
expect(response.statusCode, 200);
|
||||
expect(response.body, 'tmp');
|
||||
});
|
||||
@@ -94,7 +92,8 @@ void main() async{
|
||||
"locationAddress": "tmp"
|
||||
}
|
||||
''';
|
||||
var response = await http.post(Uri.parse('$apiAddress/fbla-api/createbusiness'),
|
||||
var response = await http.post(
|
||||
Uri.parse('$apiAddress/fbla-api/createbusiness'),
|
||||
body: json,
|
||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user