podstawy-bezpieczenstwa-kom.../lib/fuzz_dart_test.dart
2024-10-01 07:13:06 +02:00

53 lines
1.8 KiB
Dart

// ignore: file_names
import 'dart:developer';
import 'package:fuzz_dart/fuzz_dart.dart' as fuzz_dart;
import 'login-and-register.dart';
void main() {
fuzzLoginAndRegister();
}
void fuzzLoginAndRegister() {
void loginFuzz(String email, String password) {
try {
login(email, password); // Funkcja _login
} catch (e) {
log('Exception during login fuzzing: $e');
rethrow; // Propagowanie wyjątku w celu zasygnalizowania niepowodzenia testu
}
}
void registerFuzz(String name, String surname, String email, String phone, String password) {
try {
register(name, surname, email, phone, password); // Funkcja _register
} catch (e) {
log('Exception during register fuzzing: $e');
rethrow; // Propagowanie wyjątku w celu zasygnalizowania niepowodzenia testu
}
}
// Utworzenie fuzzer'a dla funkcji logowania
fuzz_dart.Fuzzer loginFuzzer = fuzz_dart.Fuzzer(
type: [fuzz_dart.AcceptedTypes.string, fuzz_dart.AcceptedTypes.string],
iterateCount: 100,
fileName: 'login-fuzzer-form',
);
// Create fuzzer for register function
fuzz_dart.Fuzzer registerFuzzer = fuzz_dart.Fuzzer(
type: [
fuzz_dart.AcceptedTypes.string, // imie
fuzz_dart.AcceptedTypes.string, // nazwisko
fuzz_dart.AcceptedTypes.string, // email
fuzz_dart.AcceptedTypes.string, // nr telefonu
fuzz_dart.AcceptedTypes.string // hasło
],
iterateCount: 100,
fileName: 'register-fuzzer-form',
);
// Uruchomienie fuzzera
loginFuzzer.iterate(loginFuzz, 'Login Fuzzing', description: "Simulates login form, returns email and password.");
registerFuzzer.iterate(registerFuzz, 'Register Fuzzing', description: "Simulates register form, returns login, password, name, surname, email, phone number");
}