This removes api authentification with token in favor of signature method. Refactorize code and clean up. It add more unit test plus code coverage in test/converage. - Added config.api.timestampTimeout - Added Helper::signRequest This calculates the request signature - Added more unit tests and extend code coverage. - Added rate limiter for web routes - Added RemoveSpaces Sanitizer on api requests - Added stress test suite - Changed AuthServiceProvider api-token to api-hmac - Changed CustomerSeeder to have at least of customer activated (for unit tests) - Changed used transation for saveing multiple models - Changed, in ServiceController generateApiToken to generateServicePassword - Changed, timestamp has to be send in request with a DateTime format, it also has to a UTC value - Composer added brianium/paratest - Composer update - Fixed case where removing single optin could be the wrong one (not for the good service) - Fixed customer delete - Fixed customer would not be resolved by brand. - Fixed Really check that request is json checking body content, preventing sending malformed requests - Remove ApiError::needAuth - Removed api_token - Removed ApiController::authenticate - Removed config.api.tokenTimeout - Removed Header check or usage because of HAProxy doing weird stuff - Removed lock files from gitignore - Removed memcached dependency - Removed unused questions resources api routes - Removed workspace file Migrations - Added unique index on services.bearer_token - Changed customer_id on customer_answer is nullable - Changed services.bearer_pwd length to 312 (the size of the token) - Dropped services.api_token and service.api_token_date
79 lines
2.3 KiB
PHP
79 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Client;
|
|
|
|
use Illuminate\Support\Str;
|
|
use LDC\LDCCRM\Utils;
|
|
use Tests\TestCase;
|
|
|
|
class UtilsTest extends TestCase
|
|
{
|
|
/**
|
|
* Test Utils validator
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testUtilsValidator()
|
|
{
|
|
$this->expectNotToPerformAssertions();
|
|
Utils::makeValidator([
|
|
'nullable' => null
|
|
], ['nullable' => 'nullable'])();
|
|
Utils::makeValidator([], ['sometimes' => 'sometimes'])();
|
|
Utils::makeValidator([
|
|
'int' => 2
|
|
], ['int' => 'int'])();
|
|
Utils::makeValidator([
|
|
'required' => 2
|
|
], ['required' => 'required'])();
|
|
Utils::makeValidator([
|
|
'bool' => 1
|
|
], ['bool' => 'bool'])();
|
|
Utils::makeValidator([
|
|
'bool' => 0
|
|
], ['bool' => 'bool'])();
|
|
Utils::makeValidator([
|
|
'bool' => true
|
|
], ['bool' => 'bool'])();
|
|
Utils::makeValidator([
|
|
'uuid' => (string)Str::uuid()
|
|
], ['uuid' => 'uuid|string'])();
|
|
Utils::makeValidator([
|
|
'date' => date('Y-m-d')
|
|
], ['date' => 'date'])();
|
|
Utils::makeValidator([
|
|
'email' => 'email@gmail.com'
|
|
], ['email' => 'email'])();
|
|
Utils::makeValidator([
|
|
'array' => []
|
|
], ['array' => 'array'])();
|
|
Utils::makeValidator([
|
|
'mixedCase' => 'azeZ'
|
|
], ['mixedCase' => 'mixedCase'])();
|
|
Utils::makeValidator([
|
|
'containDigit' => 'azeZ2'
|
|
], ['containDigit' => 'containDigit'])();
|
|
Utils::makeValidator([
|
|
'containSymbol' => 'azeZ2,'
|
|
], ['containSymbol' => 'containSymbol'])();
|
|
Utils::makeValidator([
|
|
'min' => 2,
|
|
], ['min' => 'min:2'])();
|
|
Utils::makeValidator([
|
|
'min' => 'az',
|
|
], ['min' => 'min:2']);
|
|
Utils::makeValidator([
|
|
'max' => 2,
|
|
], ['max' => 'max:2'])();
|
|
Utils::makeValidator([
|
|
'max' => 'az',
|
|
], ['max' => 'max:2'])();
|
|
Utils::makeValidator([
|
|
'date_format' => date('Y-m-d H:i:s'),
|
|
], ['date_format' => 'date_format:Y-m-d H:i:s'])();
|
|
Utils::makeValidator([
|
|
'closure' => 'value',
|
|
], ['closure' => [function ($attribute, $value, $fail) {
|
|
}]])();
|
|
}
|
|
}
|