Add nami guard
This commit is contained in:
parent
b5f3daff63
commit
56332395d9
|
@ -7,13 +7,11 @@
|
||||||
"laravel"
|
"laravel"
|
||||||
],
|
],
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{ "type": "path", "url": "./packages/laravel-nami", "options": {"symlink": true} },
|
{ "type": "path", "url": "./packages/laravel-nami", "options": {"symlink": true} }
|
||||||
{ "type": "path", "url": "./packages/agnoster-installer", "options": {"symlink": true} }
|
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5",
|
"php": "^7.2.5",
|
||||||
"aweos/agnoster-installer": "^1.0",
|
|
||||||
"fideloper/proxy": "^4.2",
|
"fideloper/proxy": "^4.2",
|
||||||
"fruitcake/laravel-cors": "^1.0",
|
"fruitcake/laravel-cors": "^1.0",
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
|
@ -32,7 +30,8 @@
|
||||||
"fzaninotto/faker": "^1.9.1",
|
"fzaninotto/faker": "^1.9.1",
|
||||||
"mockery/mockery": "^1.3.1",
|
"mockery/mockery": "^1.3.1",
|
||||||
"nunomaduro/collision": "^5.0",
|
"nunomaduro/collision": "^5.0",
|
||||||
"phpunit/phpunit": "^9.0"
|
"phpunit/phpunit": "^9.0",
|
||||||
|
"orchestra/testbench": "^6.0"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
|
@ -57,7 +56,8 @@
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Tests\\": "tests/"
|
"Tests\\": "tests/",
|
||||||
|
"Zoomyboy\\LaravelNami\\Tests\\": "packages/laravel-nami/tests/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,8 +37,7 @@ return [
|
||||||
|
|
||||||
'guards' => [
|
'guards' => [
|
||||||
'web' => [
|
'web' => [
|
||||||
'driver' => 'session',
|
'driver' => 'nami'
|
||||||
'provider' => 'users',
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
|
||||||
|
|
||||||
use App\User;
|
|
||||||
use Faker\Generator as Faker;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Model Factories
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| This directory should contain each of the model factory definitions for
|
|
||||||
| your application. Factories provide a convenient way to generate new
|
|
||||||
| model instances for testing / seeding your application's database.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
$factory->define(User::class, function (Faker $faker) {
|
|
||||||
return [
|
|
||||||
'name' => $faker->name,
|
|
||||||
'email' => $faker->unique()->safeEmail,
|
|
||||||
'email_verified_at' => now(),
|
|
||||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
|
||||||
'remember_token' => Str::random(10),
|
|
||||||
];
|
|
||||||
});
|
|
|
@ -10,6 +10,9 @@
|
||||||
<testsuite name="Feature">
|
<testsuite name="Feature">
|
||||||
<directory suffix="Test.php">./tests/Feature</directory>
|
<directory suffix="Test.php">./tests/Feature</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
<testsuite name="NamiUnit">
|
||||||
|
<directory suffix="Test.php">./packages/laravel-nami/tests/Unit</directory>
|
||||||
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<filter>
|
<filter>
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
|
|
|
@ -9,11 +9,7 @@ use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
class LoginTest extends TestCase
|
class LoginTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* A basic feature test example.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function test_it_stores_login_cookie()
|
public function test_it_stores_login_cookie()
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
|
@ -23,13 +19,16 @@ class LoginTest extends TestCase
|
||||||
$this->fakeNamiPassword(123, 'secret', [11222]);
|
$this->fakeNamiPassword(123, 'secret', [11222]);
|
||||||
|
|
||||||
$this->post('/login', [
|
$this->post('/login', [
|
||||||
'groupid' => 11222,
|
|
||||||
'mglnr' => 123,
|
'mglnr' => 123,
|
||||||
'password' => 'secret'
|
'password' => 'secret'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$cache = Cache::get('namicookie-123');
|
$cache = Cache::get('namicookie-123');
|
||||||
|
|
||||||
|
$key = session()->get('auth_key');
|
||||||
|
$cache = Cache::get("namiauth-{$key}");
|
||||||
$this->assertEquals('JSESSIONID', data_get($cache, 'cookie.0.Name'));
|
$this->assertEquals('JSESSIONID', data_get($cache, 'cookie.0.Name'));
|
||||||
$this->assertEquals('123', data_get($cache, 'data.mitgliedsnr'));
|
$this->assertEquals('secret', data_get($cache, 'credentials.password'));
|
||||||
|
$this->assertEquals(123, auth()->user()->mglnr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,8 @@ class UpdateTest extends TestCase
|
||||||
|
|
||||||
public function test_it_can_update_a_member()
|
public function test_it_can_update_a_member()
|
||||||
{
|
{
|
||||||
$this->fakeNamiMembers([
|
$this->withoutExceptionHandling();
|
||||||
[ 'gruppierungId' => 12399, 'vorname' => 'Max', 'id' => 999 ]
|
$this->login();
|
||||||
]);
|
|
||||||
|
|
||||||
$member = Member::factory()
|
$member = Member::factory()
|
||||||
->for(Country::factory())
|
->for(Country::factory())
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace Tests;
|
||||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||||
use Zoomyboy\LaravelNami\Nami;
|
use Zoomyboy\LaravelNami\Nami;
|
||||||
use Zoomyboy\LaravelNami\FakesNami;
|
use Zoomyboy\LaravelNami\FakesNami;
|
||||||
|
use Zoomyboy\LaravelNami\NamiUser;
|
||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
@ -17,4 +18,23 @@ abstract class TestCase extends BaseTestCase
|
||||||
$this->fakeNami();
|
$this->fakeNami();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function login() {
|
||||||
|
$this->fakeNamiMembers([
|
||||||
|
[ 'gruppierungId' => 12399, 'vorname' => 'Max', 'id' => 999 ]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->fakeNamiPassword(999, 'secret', [12399]);
|
||||||
|
|
||||||
|
$api = Nami::login(999, 'secret');
|
||||||
|
|
||||||
|
$this->be(new NamiUser([
|
||||||
|
'cookie' => $api->cookie->toArray(),
|
||||||
|
'credentials' => [
|
||||||
|
'mglnr' => 999,
|
||||||
|
'password' => 'secret'
|
||||||
|
]
|
||||||
|
]));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue