Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Reseller/UsersTest.php
Show First 20 Lines • Show All 360 Lines • ▼ Show 20 Lines | public function testResetGeoLock(): void | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertSame("Geo-lockin setup reset successfully.", $json['message']); | $this->assertSame("Geo-lockin setup reset successfully.", $json['message']); | ||||
$this->assertCount(2, $json); | $this->assertCount(2, $json); | ||||
$this->assertNull($user->getSetting('limit_geo')); | $this->assertNull($user->getSetting('limit_geo')); | ||||
} | } | ||||
/** | /** | ||||
* Test resync (POST /api/v4/users/<user-id>/resync) | |||||
*/ | |||||
public function testResync(): void | |||||
{ | |||||
Queue::fake(); | |||||
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | |||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | |||||
$reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | |||||
$reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | |||||
// Test unauthorized access to admin API | |||||
// Test unauthorized access | |||||
$response = $this->actingAs($user)->post("/api/v4/users/{$user->id}/resync", []); | |||||
$response->assertStatus(403); | |||||
$response = $this->actingAs($admin)->post("/api/v4/users/{$user->id}/resync", []); | |||||
$response->assertStatus(403); | |||||
$response = $this->actingAs($reseller2)->post("/api/v4/users/{$user->id}/resync", []); | |||||
$response->assertStatus(404); | |||||
// Touching admins is forbidden | |||||
$response = $this->actingAs($reseller1)->post("/api/v4/users/{$admin->id}/resync", []); | |||||
$response->assertStatus(403); | |||||
// Test resync | |||||
\Artisan::shouldReceive('call')->once()->with('user:resync', ['user' => $user->id]); | |||||
$response = $this->actingAs($reseller1)->post("/api/v4/users/{$user->id}/resync", []); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertCount(2, $json); | |||||
$this->assertSame('success', $json['status']); | |||||
$this->assertSame("User synchronization have been started.", $json['message']); | |||||
} | |||||
/** | |||||
* Test adding beta SKU (POST /api/v4/users/<user-id>/skus/beta) | * Test adding beta SKU (POST /api/v4/users/<user-id>/skus/beta) | ||||
*/ | */ | ||||
public function testAddBetaSku(): void | public function testAddBetaSku(): void | ||||
{ | { | ||||
Queue::fake(); // disable jobs | Queue::fake(); // disable jobs | ||||
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | $user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |