Removing 4 word bollocks and fixing rootless supervisor for podman
This commit is contained in:
parent
a22db4ee0f
commit
82ed2e3ce2
8 changed files with 26 additions and 160 deletions
|
|
@ -6,51 +6,13 @@ use App\Models\MagicLoginToken;
|
|||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MagicLoginTokenTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_word_token_generation_creates_exactly_4_words(): void
|
||||
{
|
||||
$token = MagicLoginToken::generateWordToken();
|
||||
|
||||
$words = explode('-', $token);
|
||||
|
||||
$this->assertCount(4, $words, 'Token should contain exactly 4 words');
|
||||
}
|
||||
|
||||
public function test_word_token_is_hyphen_separated(): void
|
||||
{
|
||||
$token = MagicLoginToken::generateWordToken();
|
||||
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/^[a-z]+-[a-z]+-[a-z]+-[a-z]+$/',
|
||||
$token,
|
||||
'Token should match pattern: word-word-word-word'
|
||||
);
|
||||
}
|
||||
|
||||
public function test_words_are_from_word_list_file(): void
|
||||
{
|
||||
$wordList = explode("\n", trim(Storage::get('words.txt')));
|
||||
$wordList = array_map('trim', $wordList);
|
||||
$wordList = array_filter($wordList);
|
||||
|
||||
$token = MagicLoginToken::generateWordToken();
|
||||
$words = explode('-', $token);
|
||||
|
||||
foreach ($words as $word) {
|
||||
$this->assertContains(
|
||||
$word,
|
||||
$wordList,
|
||||
"Word '{$word}' should be from the word list file"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_token_expiry_validation_works(): void
|
||||
{
|
||||
$token = MagicLoginToken::generate('test@example.com', '127.0.0.1', 'TestAgent');
|
||||
|
|
@ -125,7 +87,7 @@ class MagicLoginTokenTest extends TestCase
|
|||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$token->verifyToken('wrong-token-here-bad'),
|
||||
$token->verifyToken(Str::random(64)),
|
||||
'Incorrect token should not verify'
|
||||
);
|
||||
}
|
||||
|
|
@ -270,7 +232,7 @@ class MagicLoginTokenTest extends TestCase
|
|||
$this->assertEquals($token1->email_hash, $token2->email_hash);
|
||||
}
|
||||
|
||||
public function test_word_tokens_are_unique(): void
|
||||
public function test_tokens_are_unique(): void
|
||||
{
|
||||
$generatedTokens = [];
|
||||
|
||||
|
|
@ -301,24 +263,4 @@ class MagicLoginTokenTest extends TestCase
|
|||
$this->assertInstanceOf(\Illuminate\Support\Carbon::class, $token->used_at);
|
||||
}
|
||||
|
||||
public function test_4_word_token_format_validation(): void
|
||||
{
|
||||
$token = MagicLoginToken::generate('test@example.com', '127.0.0.1', 'TestAgent');
|
||||
|
||||
$plainToken = $token->plain_token;
|
||||
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/^[a-z]+-[a-z]+-[a-z]+-[a-z]+$/',
|
||||
$plainToken,
|
||||
'Token should be 4 words separated by hyphens'
|
||||
);
|
||||
|
||||
$words = explode('-', $plainToken);
|
||||
$this->assertCount(4, $words, 'Token should contain exactly 4 words');
|
||||
|
||||
foreach ($words as $word) {
|
||||
$this->assertNotEmpty($word, 'Each word should not be empty');
|
||||
$this->assertMatchesRegularExpression('/^[a-z]+$/', $word, 'Each word should contain only lowercase letters');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue