Add auto_verify_new_domains

This commit is contained in:
Mehrad 2022-12-28 16:01:48 +03:30
parent 6c7ac62d06
commit 3381d4d5da
3 changed files with 28 additions and 1 deletions

View file

@ -191,7 +191,7 @@ class Domain extends Model
*/
public function checkVerification()
{
if (App::environment('testing')) {
if (App::environment('testing') || config('anonaddy.auto_verify_new_domains')) {
return true;
}

View file

@ -202,6 +202,17 @@ return [
'auto_verify_new_recipients' => env('ANONADDY_AUTO_VERIFY_NEW_RECIPIENTS', false),
/*
|--------------------------------------------------------------------------
| Auto Verify New Domains
|--------------------------------------------------------------------------
|
| If enabled, new domains will be verified automatically
|
*/
'auto_verify_new_domains' => env('ANONADDY_AUTO_VERIFY_NEW_DOMAINS', false),
/*
|--------------------------------------------------------------------------
| Username Blacklist

View file

@ -5,6 +5,7 @@ namespace Tests\Feature\Api;
use App\Models\Domain;
use App\Models\Recipient;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\App;
use Tests\TestCase;
class DomainsTest extends TestCase
@ -61,6 +62,21 @@ class DomainsTest extends TestCase
$this->assertEquals('random.com', $response->getData()->data->domain);
}
/** @test */
public function user_can_create_new_domain_with_aa_auto_verify()
{
$this->app->detectEnvironment(fn() => 'not_testing');
config()->set('anonaddy.auto_verify_new_domains', true);
$response = $this->json('POST', '/api/v1/domains', [
'domain' => 'random.com',
]);
$response->assertStatus(201);
$this->assertEquals('random.com', $response->getData()->data->domain);
$this->assertNotEmpty($response->getData()->data->domain_verified_at);
}
/** @test */
public function user_can_not_create_the_same_domain()
{