Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

1.2 KB
Raw Blame
<?php

use App\Models\InstanceSettings;
use App\Models\OauthIdentity;
use App\Models\User;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Route;

uses(RefreshDatabase::class);

beforeEach(function () {
    InstanceSettings::forceCreate(['id' => 0]);
});

it('does not let a user change the email through the Fortify profile route', function (bool $hasSsoIdentity) {
    $user = User::factory()->create(['email' => '[email protected]']);
    if ($hasSsoIdentity) {
        OauthIdentity::create([
            'user_id' => $user->id,
            'provider' => 'github',
            'issuer' => 'github',
            'provider_user_id' => '123',
            'email' => '[email protected]',
        ]);
    }

    $this->actingAs($user)
        ->withoutMiddleware(VerifyCsrfToken::class)
        ->put('/user/profile-information', ['name' => 'Changed', 'email' => '[email protected]']);

    expect(Route::has('user-profile-information.update'))->toBeFalse()
        ->and($user->fresh()->email)->toBe('[email protected]')
        ->and($user->fresh()->name)->not->toBe('Changed');
})->with([
    'SSO user' => [true],
    'password user' => [false],
]);