Page MenuHomePhorge

D1666.1775268439.diff
No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None

D1666.1775268439.diff

diff --git a/src/app/Http/Controllers/API/V4/UsersController.php b/src/app/Http/Controllers/API/V4/UsersController.php
--- a/src/app/Http/Controllers/API/V4/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/UsersController.php
@@ -629,14 +629,14 @@
return \trans('validation.entryinvalid', ['attribute' => $attribute]);
}
- list($login, $domain) = explode('@', $email);
+ list($login, $domain) = explode('@', Str::lower($email));
if (strlen($login) === 0 || strlen($domain) === 0) {
return \trans('validation.entryinvalid', ['attribute' => $attribute]);
}
// Check if domain exists
- $domain = Domain::where('namespace', Str::lower($domain))->first();
+ $domain = Domain::where('namespace', $domain)->first();
if (empty($domain)) {
return \trans('validation.domaininvalid');
diff --git a/src/app/Observers/DomainObserver.php b/src/app/Observers/DomainObserver.php
--- a/src/app/Observers/DomainObserver.php
+++ b/src/app/Observers/DomainObserver.php
@@ -24,6 +24,8 @@
}
}
+ $domain->namespace = \strtolower($domain->namespace);
+
$domain->status |= Domain::STATUS_NEW | Domain::STATUS_ACTIVE;
}
diff --git a/src/app/Observers/UserObserver.php b/src/app/Observers/UserObserver.php
--- a/src/app/Observers/UserObserver.php
+++ b/src/app/Observers/UserObserver.php
@@ -32,6 +32,8 @@
}
}
+ $user->email = \strtolower($user->email);
+
// only users that are not imported get the benefit of the doubt.
$user->status |= User::STATUS_NEW | User::STATUS_ACTIVE;
diff --git a/src/database/seeds/local/UserSeeder.php b/src/database/seeds/local/UserSeeder.php
--- a/src/database/seeds/local/UserSeeder.php
+++ b/src/database/seeds/local/UserSeeder.php
@@ -136,8 +136,7 @@
]
);
- $jeroen->role = "admin";
-
+ $jeroen->role = 'admin';
$jeroen->save();
}
}
diff --git a/src/tests/Feature/DomainTest.php b/src/tests/Feature/DomainTest.php
--- a/src/tests/Feature/DomainTest.php
+++ b/src/tests/Feature/DomainTest.php
@@ -48,6 +48,27 @@
}
/**
+ * Test domain create/creating observer
+ */
+ public function testCreate(): void
+ {
+ Queue::fake();
+
+ $domain = Domain::create([
+ 'namespace' => 'GMAIL.COM',
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
+ ]);
+
+ $result = Domain::where('namespace', 'gmail.com')->first();
+
+ $this->assertSame('gmail.com', $result->namespace);
+ $this->assertSame($domain->id, $result->id);
+ $this->assertSame($domain->type, $result->type);
+ $this->assertSame(Domain::STATUS_NEW | Domain::STATUS_ACTIVE, $result->status);
+ }
+
+ /**
* Test domain creating jobs
*/
public function testCreateJobs(): void
diff --git a/src/tests/Feature/UserTest.php b/src/tests/Feature/UserTest.php
--- a/src/tests/Feature/UserTest.php
+++ b/src/tests/Feature/UserTest.php
@@ -56,9 +56,63 @@
}
/**
+ * Verify a wallet assigned a controller is among the accounts of the assignee.
+ */
+ public function testAccounts(): void
+ {
+ $userA = $this->getTestUser('UserAccountA@UserAccount.com');
+ $userB = $this->getTestUser('UserAccountB@UserAccount.com');
+
+ $this->assertTrue($userA->wallets()->count() == 1);
+
+ $userA->wallets()->each(
+ function ($wallet) use ($userB) {
+ $wallet->addController($userB);
+ }
+ );
+
+ $this->assertTrue($userB->accounts()->get()[0]->id === $userA->wallets()->get()[0]->id);
+ }
+
+ public function testCanDelete(): void
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testCanRead(): void
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testCanUpdate(): void
+ {
+ $this->markTestIncomplete();
+ }
+
+ /**
+ * Test user create/creating observer
+ */
+ public function testCreate(): void
+ {
+ Queue::fake();
+
+ $domain = \config('app.domain');
+
+ $user = User::create([
+ 'email' => 'USER-test@' . \strtoupper($domain)
+ ]);
+
+ $result = User::where('email', 'user-test@' . $domain)->first();
+
+ $this->assertSame('user-test@' . $domain, $result->email);
+ $this->assertSame($user->id, $result->id);
+ $this->assertSame(User::STATUS_NEW | User::STATUS_ACTIVE, $result->status);
+ }
+
+ /**
* Verify user creation process
*/
- public function testUserCreateJob(): void
+ public function testCreateJobs(): void
{
// Fake the queue, assert that no jobs were pushed...
Queue::fake();
@@ -96,45 +150,6 @@
}
/**
- * Verify a wallet assigned a controller is among the accounts of the assignee.
- */
- public function testListUserAccounts(): void
- {
- $userA = $this->getTestUser('UserAccountA@UserAccount.com');
- $userB = $this->getTestUser('UserAccountB@UserAccount.com');
-
- $this->assertTrue($userA->wallets()->count() == 1);
-
- $userA->wallets()->each(
- function ($wallet) use ($userB) {
- $wallet->addController($userB);
- }
- );
-
- $this->assertTrue($userB->accounts()->get()[0]->id === $userA->wallets()->get()[0]->id);
- }
-
- public function testAccounts(): void
- {
- $this->markTestIncomplete();
- }
-
- public function testCanDelete(): void
- {
- $this->markTestIncomplete();
- }
-
- public function testCanRead(): void
- {
- $this->markTestIncomplete();
- }
-
- public function testCanUpdate(): void
- {
- $this->markTestIncomplete();
- }
-
- /**
* Tests for User::domains()
*/
public function testDomains(): void

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 2:07 AM (18 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18776601
Default Alt Text
D1666.1775268439.diff (5 KB)

Event Timeline