Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lehecht committed Feb 24, 2025
1 parent 9c3afcf commit 16ee9be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/resources/views/update/s3.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@error('endpoint')
<p class="help-block">{{$message}}</p>
@enderror
<p class="help-block">
<p class="help-block">
This must be the full URL including the bucket name, region etc.
</p>
</div>
Expand Down
39 changes: 12 additions & 27 deletions tests/Http/Controllers/Api/UserDiskControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

class UserDiskControllerTest extends ApiTestCase
{
private $mockS3 = null;
private $mockS3;

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -47,7 +48,6 @@ public function testStore()
public function testStoreS3()
{
$this->beUser();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->postJson("/api/v1/user-disks", [
'name' => 'my disk',
Expand Down Expand Up @@ -86,7 +86,6 @@ public function testStoreS3()

public function testDuplicateNames(){
$this->beUser();

$this->mockS3->shouldReceive('canAccessDisk')->once()->andReturn([]);
$this->postJson("/api/v1/user-disks", [
'name' => 'my disk',
Expand Down Expand Up @@ -128,7 +127,6 @@ public function testDuplicateNames(){
public function testStoreS3RegionEmpty()
{
$this->beUser();

$this->mockS3->shouldReceive('canAccessDisk')->once()->andReturn([]);
$this->postJson("/api/v1/user-disks", [
'name' => 'my disk',
Expand All @@ -148,7 +146,6 @@ public function testStoreS3RegionEmpty()
public function testStoreS3PathStyle()
{
$this->beUser();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->postJson("/api/v1/user-disks", [
'name' => 'my disk',
Expand Down Expand Up @@ -374,7 +371,6 @@ public function testDestroy()
public function testStoreInvalidS3Config()
{
$this->beUser();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->postJson("/api/v1/user-disks", [
'name' => 'my disk',
Expand All @@ -384,8 +380,7 @@ public function testStoreInvalidS3Config()
'bucket' => 'ucket',
'region' => '',
'endpoint' => 'http://bucket.example.com',
])
->assertUnprocessable();
])->assertUnprocessable();

$disk = UserDisk::where('user_id', $this->user()->id)->first();
$this->assertEmpty($disk);
Expand All @@ -410,8 +405,7 @@ public function testUpdateInvalidS3Config()
$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->putJson("/api/v1/user-disks/{$disk->id}", [
'endpoint' => 'https://bucket.example.com',
])
->assertUnprocessable();
])->assertUnprocessable();

$disk = $disk->fresh();
$this->assertEquals('https://jkl.example.com', $disk->options['endpoint']);
Expand All @@ -420,7 +414,6 @@ public function testUpdateInvalidS3Config()
public function testStoreIncorrectBucketName()
{
$this->beUser();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->postJson("/api/v1/user-disks", [
'name' => 'my disk',
Expand All @@ -430,8 +423,7 @@ public function testStoreIncorrectBucketName()
'bucket' => 'ucket',
'region' => '',
'endpoint' => 'http://bucket.example.com',
])
->assertUnprocessable();
])->assertUnprocessable();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->postJson("/api/v1/user-disks", [
Expand All @@ -442,8 +434,7 @@ public function testStoreIncorrectBucketName()
'bucket' => 'bucket',
'region' => '',
'endpoint' => 'http://ucket.example.com',
])
->assertUnprocessable();
])->assertUnprocessable();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->postJson("/api/v1/user-disks", [
Expand All @@ -454,8 +445,7 @@ public function testStoreIncorrectBucketName()
'bucket' => 'ucket',
'region' => '',
'endpoint' => 'http://example.com/bucket',
])
->assertUnprocessable();
])->assertUnprocessable();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->postJson("/api/v1/user-disks", [
Expand All @@ -466,8 +456,7 @@ public function testStoreIncorrectBucketName()
'bucket' => 'bucket',
'region' => '',
'endpoint' => 'http://example.com/ucket',
])
->assertUnprocessable();
])->assertUnprocessable();
}

public function testUpdateIncorrectBucketName()
Expand Down Expand Up @@ -496,8 +485,7 @@ public function testUpdateIncorrectBucketName()
'bucket' => 'm',
'region' => 'us-east-2',
'endpoint' => 'https://onm.example.com',
])
->assertUnprocessable();
])->assertUnprocessable();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->putJson("/api/v1/user-disks/{$disk->id}", [
Expand All @@ -508,8 +496,7 @@ public function testUpdateIncorrectBucketName()
'bucket' => 'onm',
'region' => 'us-east-2',
'endpoint' => 'https://m.example.com',
])
->assertUnprocessable();
])->assertUnprocessable();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->putJson("/api/v1/user-disks/{$disk->id}", [
Expand All @@ -520,8 +507,7 @@ public function testUpdateIncorrectBucketName()
'bucket' => 'm',
'region' => 'us-east-2',
'endpoint' => 'https://example.com/onm',
])
->assertUnprocessable();
])->assertUnprocessable();

$this->mockS3->shouldReceive('canAccessDisk')->never();
$this->putJson("/api/v1/user-disks/{$disk->id}", [
Expand All @@ -532,7 +518,6 @@ public function testUpdateIncorrectBucketName()
'bucket' => 'onm',
'region' => 'us-east-2',
'endpoint' => 'https://example.com/m',
])
->assertUnprocessable();
])->assertUnprocessable();
}
}

0 comments on commit 16ee9be

Please sign in to comment.