login tester for mailing
This commit is contained in:
1 parent
5cc4fd0d10
commit
d862ed1102
1 file changed
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// loginTest.php
|
||||
|
||||
$loginUrl = "https://backend.blackpi.ipv64.net/login.php"; // URL zu deinem Login-Script
|
||||
|
||||
// Testfälle
|
||||
$tests = [
|
||||
[
|
||||
'username' => 'Bruno', // korrektes Testkonto
|
||||
'password' => 'bBHofurUJWKzPE8Z', // korrektes Passwort
|
||||
'expected' => true,
|
||||
'description' => 'Erfolgreiches Login'
|
||||
],
|
||||
[
|
||||
'username' => 'admin',
|
||||
'password' => 'falschespasswort',
|
||||
'expected' => false,
|
||||
'description' => 'Fehlerhaftes Login'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($tests as $test) {
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $loginUrl);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
||||
'username' => $test['username'],
|
||||
'password' => $test['password']
|
||||
]));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); // Wichtige Info: redirect erkennen
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
$body = substr($response, $headerSize);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
// Prüfen, ob Login erfolgreich war: Redirect auf index.php oder Session gesetzt
|
||||
if (strpos($response, "Location: index.php") !== false || strpos($body, "Login fehlgeschlagen") === false) {
|
||||
$success = true;
|
||||
} else {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if ($success === $test['expected']) {
|
||||
echo "[PASS] {$test['description']}\n";
|
||||
} else {
|
||||
echo "[FAIL] {$test['description']}\n";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user