tipo: modificación del cpanel y gitignore de la carpeta vendor

This commit is contained in:
2026-07-07 11:35:09 -06:00
parent a0c91dc567
commit 676ef0d506
8510 changed files with 1132803 additions and 4 deletions
@@ -0,0 +1,34 @@
<?php
use App\Models\User;
use Illuminate\Support\Str;
use Laravel\Jetstream\Features;
test('api token permissions can be updated', function () {
if (Features::hasTeamFeatures()) {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
} else {
$this->actingAs($user = User::factory()->create());
}
$token = $user->tokens()->create([
'name' => 'Test Token',
'token' => Str::random(40),
'abilities' => ['create', 'read'],
]);
$this->put('/user/api-tokens/'.$token->id, [
'name' => $token->name,
'permissions' => [
'delete',
'missing-permission',
],
]);
expect($user->fresh()->tokens->first())
->can('delete')->toBeTrue()
->can('read')->toBeFalse()
->can('missing-permission')->toBeFalse();
})->skip(function () {
return ! Features::hasApiFeatures();
}, 'API support is not enabled.');
@@ -0,0 +1,13 @@
<?php
use App\Models\User;
test('other browser sessions can be logged out', function () {
$this->actingAs(User::factory()->create());
$response = $this->delete('/user/other-browser-sessions', [
'password' => 'password',
]);
$response->assertSessionHasNoErrors();
});
@@ -0,0 +1,28 @@
<?php
use App\Models\User;
use Laravel\Jetstream\Features;
test('api tokens can be created', function () {
if (Features::hasTeamFeatures()) {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
} else {
$this->actingAs($user = User::factory()->create());
}
$this->post('/user/api-tokens', [
'name' => 'Test Token',
'permissions' => [
'read',
'update',
],
]);
expect($user->fresh()->tokens)->toHaveCount(1);
expect($user->fresh()->tokens->first())
->name->toEqual('Test Token')
->can('read')->toBeTrue()
->can('delete')->toBeFalse();
})->skip(function () {
return ! Features::hasApiFeatures();
}, 'API support is not enabled.');
@@ -0,0 +1,14 @@
<?php
use App\Models\User;
test('teams can be created', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$this->post('/teams', [
'name' => 'Test Team',
]);
expect($user->fresh()->ownedTeams)->toHaveCount(2);
expect($user->fresh()->ownedTeams()->latest('id')->first()->name)->toEqual('Test Team');
});
@@ -0,0 +1,28 @@
<?php
use App\Models\User;
use Laravel\Jetstream\Features;
test('user accounts can be deleted', function () {
$this->actingAs($user = User::factory()->create());
$this->delete('/user', [
'password' => 'password',
]);
expect($user->fresh())->toBeNull();
})->skip(function () {
return ! Features::hasAccountDeletionFeatures();
}, 'Account deletion is not enabled.');
test('correct password must be provided before account can be deleted', function () {
$this->actingAs($user = User::factory()->create());
$this->delete('/user', [
'password' => 'wrong-password',
]);
expect($user->fresh())->not->toBeNull();
})->skip(function () {
return ! Features::hasAccountDeletionFeatures();
}, 'Account deletion is not enabled.');
@@ -0,0 +1,25 @@
<?php
use App\Models\User;
use Illuminate\Support\Str;
use Laravel\Jetstream\Features;
test('api tokens can be deleted', function () {
if (Features::hasTeamFeatures()) {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
} else {
$this->actingAs($user = User::factory()->create());
}
$token = $user->tokens()->create([
'name' => 'Test Token',
'token' => Str::random(40),
'abilities' => ['create', 'read'],
]);
$this->delete('/user/api-tokens/'.$token->id);
expect($user->fresh()->tokens)->toHaveCount(0);
})->skip(function () {
return ! Features::hasApiFeatures();
}, 'API support is not enabled.');
@@ -0,0 +1,29 @@
<?php
use App\Models\Team;
use App\Models\User;
test('teams can be deleted', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$user->ownedTeams()->save($team = Team::factory()->make([
'personal_team' => false,
]));
$team->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'test-role']
);
$this->delete('/teams/'.$team->id);
expect($team->fresh())->toBeNull();
expect($otherUser->fresh()->teams)->toHaveCount(0);
});
test('personal teams cant be deleted', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$this->delete('/teams/'.$user->currentTeam->id);
expect($user->currentTeam->fresh())->not->toBeNull();
});
@@ -0,0 +1,40 @@
<?php
use App\Models\User;
use Illuminate\Support\Facades\Mail;
use Laravel\Jetstream\Features;
use Laravel\Jetstream\Mail\TeamInvitation;
test('team members can be invited to team', function () {
Mail::fake();
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$this->post('/teams/'.$user->currentTeam->id.'/members', [
'email' => 'test@example.com',
'role' => 'admin',
]);
Mail::assertSent(TeamInvitation::class);
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(1);
})->skip(function () {
return ! Features::sendsTeamInvitations();
}, 'Team invitations not enabled.');
test('team member invitations can be cancelled', function () {
Mail::fake();
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$invitation = $user->currentTeam->teamInvitations()->create([
'email' => 'test@example.com',
'role' => 'admin',
]);
$this->delete('/team-invitations/'.$invitation->id);
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(0);
})->skip(function () {
return ! Features::sendsTeamInvitations();
}, 'Team invitations not enabled.');
@@ -0,0 +1,27 @@
<?php
use App\Models\User;
test('users can leave teams', function () {
$user = User::factory()->withPersonalTeam()->create();
$user->currentTeam->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'admin']
);
$this->actingAs($otherUser);
$this->delete('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id);
expect($user->currentTeam->fresh()->users)->toHaveCount(0);
});
test('team owners cant leave their own team', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$user->id);
$response->assertSessionHasErrorsIn('removeTeamMember', ['team']);
expect($user->currentTeam->fresh())->not->toBeNull();
});
@@ -0,0 +1,16 @@
<?php
use App\Models\User;
test('profile information can be updated', function () {
$this->actingAs($user = User::factory()->create());
$this->put('/user/profile-information', [
'name' => 'Test Name',
'email' => 'test@example.com',
]);
expect($user->fresh())
->name->toEqual('Test Name')
->email->toEqual('test@example.com');
});
@@ -0,0 +1,29 @@
<?php
use App\Models\User;
test('team members can be removed from teams', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$user->currentTeam->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'admin']
);
$this->delete('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id);
expect($user->currentTeam->fresh()->users)->toHaveCount(0);
});
test('only team owner can remove team members', function () {
$user = User::factory()->withPersonalTeam()->create();
$user->currentTeam->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'admin']
);
$this->actingAs($otherUser);
$response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$user->id);
$response->assertStatus(403);
});
@@ -0,0 +1,51 @@
<?php
use App\Models\User;
use Laravel\Fortify\Features;
test('two factor authentication can be enabled', function () {
$this->actingAs($user = User::factory()->create());
$this->withSession(['auth.password_confirmed_at' => time()]);
$this->post('/user/two-factor-authentication');
expect($user->fresh()->two_factor_secret)->not->toBeNull();
expect($user->fresh()->recoveryCodes())->toHaveCount(8);
})->skip(function () {
return ! Features::canManageTwoFactorAuthentication();
}, 'Two factor authentication is not enabled.');
test('recovery codes can be regenerated', function () {
$this->actingAs($user = User::factory()->create());
$this->withSession(['auth.password_confirmed_at' => time()]);
$this->post('/user/two-factor-authentication');
$this->post('/user/two-factor-recovery-codes');
$user = $user->fresh();
$this->post('/user/two-factor-recovery-codes');
expect($user->recoveryCodes())->toHaveCount(8);
expect(array_diff($user->recoveryCodes(), $user->fresh()->recoveryCodes()))->toHaveCount(8);
})->skip(function () {
return ! Features::canManageTwoFactorAuthentication();
}, 'Two factor authentication is not enabled.');
test('two factor authentication can be disabled', function () {
$this->actingAs($user = User::factory()->create());
$this->withSession(['auth.password_confirmed_at' => time()]);
$this->post('/user/two-factor-authentication');
$this->assertNotNull($user->fresh()->two_factor_secret);
$this->delete('/user/two-factor-authentication');
expect($user->fresh()->two_factor_secret)->toBeNull();
})->skip(function () {
return ! Features::canManageTwoFactorAuthentication();
}, 'Two factor authentication is not enabled.');
@@ -0,0 +1,44 @@
<?php
use App\Models\User;
use Illuminate\Support\Facades\Hash;
test('password can be updated', function () {
$this->actingAs($user = User::factory()->create());
$this->put('/user/password', [
'current_password' => 'password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);
expect(Hash::check('new-password', $user->fresh()->password))->toBeTrue();
});
test('current password must be correct', function () {
$this->actingAs($user = User::factory()->create());
$response = $this->put('/user/password', [
'current_password' => 'wrong-password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);
$response->assertSessionHasErrors();
expect(Hash::check('password', $user->fresh()->password))->toBeTrue();
});
test('new passwords must match', function () {
$this->actingAs($user = User::factory()->create());
$response = $this->put('/user/password', [
'current_password' => 'password',
'password' => 'new-password',
'password_confirmation' => 'wrong-password',
]);
$response->assertSessionHasErrors();
expect(Hash::check('password', $user->fresh()->password))->toBeTrue();
});
@@ -0,0 +1,37 @@
<?php
use App\Models\User;
test('team member roles can be updated', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$user->currentTeam->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'admin']
);
$this->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id, [
'role' => 'editor',
]);
expect($otherUser->fresh()->hasTeamRole(
$user->currentTeam->fresh(), 'editor'
))->toBeTrue();
});
test('only team owner can update team member roles', function () {
$user = User::factory()->withPersonalTeam()->create();
$user->currentTeam->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'admin']
);
$this->actingAs($otherUser);
$this->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id, [
'role' => 'editor',
]);
expect($otherUser->fresh()->hasTeamRole(
$user->currentTeam->fresh(), 'admin'
))->toBeTrue();
});
@@ -0,0 +1,14 @@
<?php
use App\Models\User;
test('team names can be updated', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$this->put('/teams/'.$user->currentTeam->id, [
'name' => 'Test Team',
]);
expect($user->fresh()->ownedTeams)->toHaveCount(1);
expect($user->currentTeam->fresh()->name)->toEqual('Test Team');
});