Skip to content

Commit

Permalink
ShipSaaS Laravel JWKS
Browse files Browse the repository at this point in the history
  • Loading branch information
sethsandaru committed Oct 15, 2023
1 parent 5c07f95 commit 1c181ee
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
25 changes: 13 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".php">./src/Configs</directory>
<directory suffix=".php">./src/Routes</directory>
<file>./src/ShipSaasLaravelJwksServiceProvider.php</file>
</exclude>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<testsuites>
<testsuite name="Laravel JWKS Test Suite">
<directory suffix=".php">./tests/</directory>
<exclude>./tests/TestCase.php</exclude>
<exclude>./tests/TestCase.php</exclude>
</testsuite>
</testsuites>
<php>
<ini name="memory_limit" value="-1"/>
<env name="APP_KEY" value="base64:vERr555bmE1jw0bfIXthCve2bmS2CQimxGaODqTsNPo="/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".php">./src/Configs</directory>
<directory suffix=".php">./src/Routes</directory>
<file>./src/ShipSaasLaravelJwksServiceProvider.php</file>
</exclude>
</source>
</phpunit>
5 changes: 0 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ abstract class TestCase extends BaseTestCase
{
use WithFaker;

protected function setUp(): void
{
parent::setUp();
}

protected function getPackageProviders($app): array
{
return [
Expand Down
45 changes: 45 additions & 0 deletions tests/Unit/Entities/KeySetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace ShipSaasLaravelJwks\Tests\Unit\Entities;

use ShipSaasLaravelJwks\Entities\Key;
use ShipSaasLaravelJwks\Entities\KeyConfiguration;
use ShipSaasLaravelJwks\Entities\KeySet;
use ShipSaasLaravelJwks\Tests\TestCase;

class KeySetTest extends TestCase
{
public function testKetSetCanAddAndParseToArray()
{
$keyset = new KeySet();

$keyContent = file_get_contents(__DIR__ . '/../../__fixtures__/public-key.pub');
$key = Key::fromRaw($keyContent, new KeyConfiguration());

$keyset->add($key);

$array = $keyset->toArray();

$this->assertNotEmpty($array);

$this->assertSame($array[0]['alg'], 'RS256');
$this->assertSame($array[0]['kty'], 'RSA');
}

public function testKetSetCanAddAndParseToString()
{
$keyset = new KeySet();

$keyContent = file_get_contents(__DIR__ . '/../../__fixtures__/public-key.pub');
$key = Key::fromRaw($keyContent, new KeyConfiguration());

$keyset->add($key);

$string = $keyset->__toString();

$this->assertNotEmpty($string);

$this->assertStringContainsString('RS256', $string);
$this->assertStringContainsString('RSA', $string);
}
}

0 comments on commit 1c181ee

Please sign in to comment.