handle team invitation for non registered user

This commit is contained in:
Čarodej
2022-02-12 11:28:08 +01:00
parent 4498461e70
commit 00c6562719
18 changed files with 216 additions and 51 deletions

View File

@@ -41,7 +41,7 @@ class HomepageTest extends TestCase
{
$this->get('/')
->assertStatus(200)
->assertSee('setup-disclaimer')
->assertSee('installation-needed')
->assertSee('VueFileManager');
}

View File

@@ -190,12 +190,12 @@ class SettingsTest extends TestCase
$this
->actingAs($admin)
->postJson('/api/admin/settings/email', [
'driver' => 'smtp',
'host' => 'smtp.email.com',
'port' => 25,
'username' => 'john@doe.com',
'password' => 'secret',
'encryption' => 'tls',
'mailDriver' => 'smtp',
'smtp.host' => 'smtp.email.com',
'smtp.port' => 25,
'smtp.username' => 'john@doe.com',
'smtp.password' => 'secret',
'smtp.encryption' => 'tls',
])->assertStatus(204);
}
}

View File

@@ -21,7 +21,7 @@ class SetupWizardTest extends TestCase
$this->postJson('/api/setup/purchase-code', [
'purchaseCode' => '8624194e-3156-4cd0-944e-3440fcecdacb',
])->assertStatus(204);
])->assertStatus(201);
}
/**

View File

@@ -1,4 +1,5 @@
<?php
namespace Tests\Domain\Sharing;
use Tests\TestCase;
@@ -193,7 +194,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (! $is_protected) {
if (!$is_protected) {
$this->getJson("/api/browse/folders/$root->id/$share->token")
->assertStatus(200)
->assertJsonFragment([
@@ -260,10 +261,11 @@ class VisitorBrowseTest extends TestCase
$tree = [
[
'id' => $share->item_id,
'name' => 'Home',
'location' => 'public',
'folders' => [
'name' => 'Home',
'location' => 'public',
'isMovable' => true,
'isOpen' => true,
'folders' => [
[
'id' => $folder_level_2->id,
'parent_id' => $folder_level_1->id,
@@ -308,7 +310,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (! $is_protected) {
if (!$is_protected) {
$this->getJson("/api/browse/navigation/$share->token")
->assertStatus(200)
->assertExactJson($tree);
@@ -360,7 +362,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (! $is_protected) {
if (!$is_protected) {
$this->getJson("/api/browse/search/$share->token?query=doc")
->assertStatus(200)
->assertJsonFragment([
@@ -411,7 +413,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (! $is_protected) {
if (!$is_protected) {
$this->getJson("/api/browse/search/$share->token?query=doc")
->assertStatus(200)
->assertJsonFragment([]);
@@ -458,7 +460,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (! $is_protected) {
if (!$is_protected) {
$this->getJson("/api/browse/file/$share->token")
->assertStatus(200)
->assertJsonFragment([

View File

@@ -300,6 +300,7 @@ class VisitorManipulatingTest extends TestCase
collect([true, false])
->each(function ($is_protected) {
$user = User::factory()
->hasSettings()
->create();
$folder = Folder::factory(Folder::class)

View File

@@ -44,7 +44,7 @@ class TeamManagementTest extends TestCase
/**
* @test
*/
public function it_accept_team_folder_invite()
public function it_accept_team_folder_invite_as_registered_user()
{
$member = User::factory()
->create([
@@ -59,7 +59,7 @@ class TeamManagementTest extends TestCase
'parent_id' => $folder->id,
'email' => $member->email,
'status' => 'pending',
'permission' => 'can-edit',
'permission' => 'can-view',
]);
$this
@@ -75,8 +75,69 @@ class TeamManagementTest extends TestCase
->assertDatabaseHas('team_folder_members', [
'parent_id' => $folder->id,
'user_id' => $member->id,
'permission' => 'can-view',
]);
}
/**
* @test
*/
public function it_accept_team_folder_invite_as_guest_user()
{
$folder = Folder::factory()
->create();
$invitation = TeamFolderInvitation::factory()
->create([
'parent_id' => $folder->id,
'email' => 'howdy@hi5ve.digital',
'status' => 'pending',
'permission' => 'can-edit',
]);
$this
->putJson("/api/teams/invitations/{$invitation->id}")
->assertNoContent();
$this
->assertDatabaseHas('team_folder_invitations', [
'parent_id' => $folder->id,
'status' => 'waiting-for-registration',
])
->assertDatabaseMissing('team_folder_members', [
'parent_id' => $folder->id,
'permission' => 'can-edit',
]);
}
/**
* @test
*/
public function it_apply_accepted_invitation_after_user_registration()
{
$invitation = TeamFolderInvitation::factory()
->create([
'email' => 'john@doe.com',
'status' => 'waiting-for-registration',
]);
$this->postJson('api/register', [
'email' => 'john@doe.com',
'password' => 'SecretPassword',
'password_confirmation' => 'SecretPassword',
'name' => 'John Doe',
])->assertStatus(201);
$this
->assertDatabaseHas('team_folder_invitations', [
'parent_id' => $invitation->parent_id,
'status' => 'accepted',
])
->assertDatabaseHas('team_folder_members', [
'parent_id' => $invitation->parent_id,
'user_id' => User::first()->id,
'permission' => $invitation->permission,
]);
}
/**