. */ namespace Tests\Feature; use Account; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Password; use App\Account as DBAccount; class AccountProvisioningTest extends TestCase { use RefreshDatabase; protected $route = '/provisioning'; protected $accountRoute = '/provisioning/me'; protected $method = 'GET'; protected $pnProvider = 'provider'; protected $pnParam = 'param'; protected $pnPrid = 'id'; public function testBaseProvisioning() { $response = $this->get($this->route); $response->assertStatus(200); $response->assertHeader('Content-Type', 'application/xml'); $response->assertDontSee('ha1'); } public function testAuthenticatedProvisioning() { $response = $this->get($this->accountRoute); $response->assertStatus(302); $password = Password::factory()->create(); $password->account->generateApiKey(); // Ensure that we get the authentication password once $response = $this->keyAuthenticated($password->account) ->get($this->accountRoute) ->assertStatus(200) ->assertHeader('Content-Type', 'application/xml') ->assertSee('ha1') ->assertSee('contacts-vcard-list'); // And then twice $response = $this->keyAuthenticated($password->account) ->get($this->accountRoute) ->assertStatus(200) ->assertHeader('Content-Type', 'application/xml') ->assertSee('ha1'); } public function testConfirmationKeyProvisioning() { $response = $this->get($this->route.'/1234'); $response->assertStatus(200); $response->assertHeader('Content-Type', 'application/xml'); $response->assertDontSee('ha1'); $password = Password::factory()->create(); $password->account->generateApiKey(); $password->account->activated = false; $password->account->save(); // Ensure that we get the authentication password once $response = $this->get($this->route.'/'.$password->account->confirmation_key) ->assertStatus(200) ->assertHeader('Content-Type', 'application/xml') ->assertSee('ha1'); // Check if the account has been activated $this->assertEquals(true, DBAccount::where('id', $password->account->id)->first()->activated); // And then twice $response = $this->get($this->route.'/'.$password->account->confirmation_key) ->assertStatus(200) ->assertHeader('Content-Type', 'application/xml') ->assertDontSee('ha1'); } }