Skip to content

Commit

Permalink
Tests creating a JWK with empty secret.
Browse files Browse the repository at this point in the history
  • Loading branch information
little-apps committed Jun 1, 2024
1 parent d456a88 commit 034702c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Features/KeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
use LittleApps\LittleJWT\Build\Builder;
use LittleApps\LittleJWT\Exceptions\HashAlgorithmNotFoundException;
use LittleApps\LittleJWT\Exceptions\InvalidHashAlgorithmException;
use LittleApps\LittleJWT\Exceptions\InvalidJWKException;
use LittleApps\LittleJWT\Exceptions\MissingKeyException;
use LittleApps\LittleJWT\Facades\LittleJWT;
use LittleApps\LittleJWT\Factories\KeyBuilder;
use LittleApps\LittleJWT\Factories\OpenSSLBuilder;
use LittleApps\LittleJWT\JWK\JWKValidator;
use LittleApps\LittleJWT\Testing\TestValidator;
use LittleApps\LittleJWT\Tests\Concerns\InteractsWithLittleJWT;
use LittleApps\LittleJWT\Tests\TestCase;
Expand Down Expand Up @@ -301,6 +303,24 @@ public function test_config_file_missing_alg()
$this->assertNotNull($signed);
}

/**
* Tests creating a JWK with empty secret.
*
* @return void
*/
public function test_empty_jwk_phrase() {
$this->expectException(InvalidJWKException::class);

$jwk = KeyBuilder::buildFromConfig([
'default' => KeyBuilder::KEY_SECRET,
'secret' => [
'phrase' => ''
]
]);

JWKValidator::validate($jwk);
}

/**
* Creates and validates a JWT with the same JWK
*
Expand Down

0 comments on commit 034702c

Please sign in to comment.