Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/SignupTest.php
Show First 20 Lines • Show All 447 Lines • ▼ Show 20 Lines | public function testSignupInvalidInput(array $result): void | ||||
$response->assertStatus(422); | $response->assertStatus(422); | ||||
$this->assertSame('error', $json['status']); | $this->assertSame('error', $json['status']); | ||||
$this->assertCount(2, $json['errors']); | $this->assertCount(2, $json['errors']); | ||||
$this->assertArrayHasKey('password', $json['errors']); | $this->assertArrayHasKey('password', $json['errors']); | ||||
$this->assertArrayHasKey('domain', $json['errors']); | $this->assertArrayHasKey('domain', $json['errors']); | ||||
$domain = $this->getPublicDomain(); | $domain = $this->getPublicDomain(); | ||||
// Login too short | // Login too short, password too short | ||||
$data = [ | $data = [ | ||||
'login' => '1', | 'login' => '1', | ||||
'domain' => $domain, | 'domain' => $domain, | ||||
'password' => 'test', | 'password' => 'test', | ||||
'password_confirmation' => 'test', | 'password_confirmation' => 'test', | ||||
]; | ]; | ||||
$response = $this->post('/api/auth/signup', $data); | $response = $this->post('/api/auth/signup', $data); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$response->assertStatus(422); | $response->assertStatus(422); | ||||
$this->assertSame('error', $json['status']); | $this->assertSame('error', $json['status']); | ||||
$this->assertCount(1, $json['errors']); | $this->assertCount(2, $json['errors']); | ||||
$this->assertArrayHasKey('login', $json['errors']); | $this->assertArrayHasKey('login', $json['errors']); | ||||
$this->assertArrayHasKey('password', $json['errors']); | |||||
// Missing codes | // Missing codes | ||||
$data = [ | $data = [ | ||||
'login' => 'login-valid', | 'login' => 'login-valid', | ||||
'domain' => $domain, | 'domain' => $domain, | ||||
'password' => 'test', | 'password' => 'testtest', | ||||
'password_confirmation' => 'test', | 'password_confirmation' => 'testtest', | ||||
]; | ]; | ||||
$response = $this->post('/api/auth/signup', $data); | $response = $this->post('/api/auth/signup', $data); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$response->assertStatus(422); | $response->assertStatus(422); | ||||
$this->assertSame('error', $json['status']); | $this->assertSame('error', $json['status']); | ||||
$this->assertCount(2, $json['errors']); | $this->assertCount(2, $json['errors']); | ||||
$this->assertArrayHasKey('code', $json['errors']); | $this->assertArrayHasKey('code', $json['errors']); | ||||
$this->assertArrayHasKey('short_code', $json['errors']); | $this->assertArrayHasKey('short_code', $json['errors']); | ||||
// Data with invalid short_code | // Data with invalid short_code | ||||
$data = [ | $data = [ | ||||
'login' => 'TestLogin', | 'login' => 'TestLogin', | ||||
'domain' => $domain, | 'domain' => $domain, | ||||
'password' => 'test', | 'password' => 'testtest', | ||||
'password_confirmation' => 'test', | 'password_confirmation' => 'testtest', | ||||
'code' => $result['code'], | 'code' => $result['code'], | ||||
'short_code' => 'XXXX', | 'short_code' => 'XXXX', | ||||
]; | ]; | ||||
$response = $this->post('/api/auth/signup', $data); | $response = $this->post('/api/auth/signup', $data); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$response->assertStatus(422); | $response->assertStatus(422); | ||||
$this->assertSame('error', $json['status']); | $this->assertSame('error', $json['status']); | ||||
$this->assertCount(1, $json['errors']); | $this->assertCount(1, $json['errors']); | ||||
$this->assertArrayHasKey('short_code', $json['errors']); | $this->assertArrayHasKey('short_code', $json['errors']); | ||||
$code = SignupCode::find($result['code']); | $code = SignupCode::find($result['code']); | ||||
// Data with invalid voucher | // Data with invalid voucher | ||||
$data = [ | $data = [ | ||||
'login' => 'TestLogin', | 'login' => 'TestLogin', | ||||
'domain' => $domain, | 'domain' => $domain, | ||||
'password' => 'test', | 'password' => 'testtest', | ||||
'password_confirmation' => 'test', | 'password_confirmation' => 'testtest', | ||||
'code' => $result['code'], | 'code' => $result['code'], | ||||
'short_code' => $code->short_code, | 'short_code' => $code->short_code, | ||||
'voucher' => 'XXX', | 'voucher' => 'XXX', | ||||
]; | ]; | ||||
$response = $this->post('/api/auth/signup', $data); | $response = $this->post('/api/auth/signup', $data); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$response->assertStatus(422); | $response->assertStatus(422); | ||||
$this->assertSame('error', $json['status']); | $this->assertSame('error', $json['status']); | ||||
$this->assertCount(1, $json['errors']); | $this->assertCount(1, $json['errors']); | ||||
$this->assertArrayHasKey('voucher', $json['errors']); | $this->assertArrayHasKey('voucher', $json['errors']); | ||||
// Valid code, invalid login | // Valid code, invalid login | ||||
$data = [ | $data = [ | ||||
'login' => 'żżżżżż', | 'login' => 'żżżżżż', | ||||
'domain' => $domain, | 'domain' => $domain, | ||||
'password' => 'test', | 'password' => 'testtest', | ||||
'password_confirmation' => 'test', | 'password_confirmation' => 'testtest', | ||||
'code' => $result['code'], | 'code' => $result['code'], | ||||
'short_code' => $code->short_code, | 'short_code' => $code->short_code, | ||||
]; | ]; | ||||
$response = $this->post('/api/auth/signup', $data); | $response = $this->post('/api/auth/signup', $data); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$response->assertStatus(422); | $response->assertStatus(422); | ||||
Show All 12 Lines | public function testSignupValidInput(array $result): void | ||||
$queue = Queue::fake(); | $queue = Queue::fake(); | ||||
$domain = $this->getPublicDomain(); | $domain = $this->getPublicDomain(); | ||||
$identity = \strtolower('SignupLogin@') . $domain; | $identity = \strtolower('SignupLogin@') . $domain; | ||||
$code = SignupCode::find($result['code']); | $code = SignupCode::find($result['code']); | ||||
$data = [ | $data = [ | ||||
'login' => 'SignupLogin', | 'login' => 'SignupLogin', | ||||
'domain' => $domain, | 'domain' => $domain, | ||||
'password' => 'test', | 'password' => 'testtest', | ||||
'password_confirmation' => 'test', | 'password_confirmation' => 'testtest', | ||||
'code' => $code->code, | 'code' => $code->code, | ||||
'short_code' => $code->short_code, | 'short_code' => $code->short_code, | ||||
'voucher' => 'TEST', | 'voucher' => 'TEST', | ||||
]; | ]; | ||||
$response = $this->post('/api/auth/signup', $data); | $response = $this->post('/api/auth/signup', $data); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | public function testSignupGroupAccount(): void | ||||
$this->assertSame([], $result['domains']); | $this->assertSame([], $result['domains']); | ||||
// Final signup request | // Final signup request | ||||
$login = 'admin'; | $login = 'admin'; | ||||
$domain = 'external.com'; | $domain = 'external.com'; | ||||
$data = [ | $data = [ | ||||
'login' => $login, | 'login' => $login, | ||||
'domain' => $domain, | 'domain' => $domain, | ||||
'password' => 'test', | 'password' => 'testtest', | ||||
'password_confirmation' => 'test', | 'password_confirmation' => 'testtest', | ||||
'code' => $code->code, | 'code' => $code->code, | ||||
'short_code' => $code->short_code, | 'short_code' => $code->short_code, | ||||
]; | ]; | ||||
$response = $this->post('/api/auth/signup', $data); | $response = $this->post('/api/auth/signup', $data); | ||||
$result = $response->json(); | $result = $response->json(); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | public function testSignupViaInvitation(): void | ||||
$invitation = SI::create(['email' => 'email1@ext.com']); | $invitation = SI::create(['email' => 'email1@ext.com']); | ||||
$post = [ | $post = [ | ||||
'invitation' => 'abc', | 'invitation' => 'abc', | ||||
'first_name' => 'Signup', | 'first_name' => 'Signup', | ||||
'last_name' => 'User', | 'last_name' => 'User', | ||||
'login' => 'test-inv', | 'login' => 'test-inv', | ||||
'domain' => 'kolabnow.com', | 'domain' => 'kolabnow.com', | ||||
'password' => 'test', | 'password' => 'testtest', | ||||
'password_confirmation' => 'test', | 'password_confirmation' => 'testtest', | ||||
]; | ]; | ||||
// Test invalid invitation identifier | // Test invalid invitation identifier | ||||
$response = $this->post('/api/auth/signup', $post); | $response = $this->post('/api/auth/signup', $post); | ||||
$response->assertStatus(404); | $response->assertStatus(404); | ||||
// Test valid input | // Test valid input | ||||
$post['invitation'] = $invitation->id; | $post['invitation'] = $invitation->id; | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |