Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Update Fixtures to use Saloon v2 format
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelMwangiW committed Jan 30, 2024
1 parent d78e2f4 commit 6c3d019
Show file tree
Hide file tree
Showing 45 changed files with 533 additions and 1,451 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"php": "^8.1",
"guzzlehttp/guzzle": "^7.2",
"illuminate/contracts": "^10.0",
"sammyjo20/saloon-laravel": "^2.0",
"saloonphp/laravel-plugin": "^2.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
Expand Down
3 changes: 2 additions & 1 deletion src/Domain/FirewallRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use SamuelMwangiW\Linode\DTO\FirewallRulesDTO;
use SamuelMwangiW\Linode\Factory\FirewallRulesFactory;
use SamuelMwangiW\Linode\Saloon\AuthenticatedConnector;
use SamuelMwangiW\Linode\Saloon\BaseConnector;
use SamuelMwangiW\Linode\Saloon\Requests\Firewall\Rules\ListRequest;

Expand All @@ -20,7 +21,7 @@ class FirewallRule
*/
public function show($firewallId): FirewallRulesDTO
{
$connector = BaseConnector::make();
$connector = AuthenticatedConnector::make();
$request = ListRequest::make($firewallId);

return FirewallRulesFactory::make(
Expand Down
3 changes: 2 additions & 1 deletion src/Factory/RegionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public static function make(array $data): RegionDTO
resolvers: collect(
explode(',', $data['resolvers']['ipv4'])
)
->map(fn ($ip) => new IPAddress($ip)),
->map(fn (string $ip) => trim($ip))
->map(fn (string $ip) => new IPAddress($ip)),
capabilities: collect($data['capabilities']),
);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
->tap(fn () => fakeSaloonRequest(GetRequest::class))
->expect(fn () => Linode::account())
->toBeInstanceOf(AccountDTO::class)
->company->toBe('mwangithegreat')
->email->toBe('[email protected]')
->uid->toBe('D09103B1-20FE-11EA-B88C0CC47AEB2714');
->company->toBe('Test Company Unlimited')
->email->toBe('[email protected]')
->uid->toBe('D09103B1-FFFF-AAAA-B88C000000000004');
4 changes: 2 additions & 2 deletions tests/Datasets/Firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

declare(strict_types=1);

dataset('firewall-id', [71435]);
dataset('delete-id', [87488]);
dataset('firewall-id', [334556]);
dataset('delete-id', [334528]);
10 changes: 5 additions & 5 deletions tests/Datasets/Instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

dataset('instance-id', [38948459]);
dataset('delete-instance-id', [38948357]);
dataset('instance-id', [54472202]);
dataset('delete-instance-id', [54472029]);
dataset('image-id', ['linode/ubuntu20.04']);
dataset(
name: 'disk',
dataset: [
fn () => ['disk_id' => 61246188, 'label' => 'backup_disk', 'description' => 'Created in tests, delete'],
fn () => ['disk_id' => 48694547, 'label' => 'backup_disk', 'description' => 'Created in tests, delete'],
]
);

Expand All @@ -20,7 +20,7 @@
'image' => 'linode/ubuntu20.04',
'private_ip' => true,
'label' => 'pest-test-' . fake()->numerify(),
'root_pass' => fake()->password(),
'root_pass' => fake()->password(20),
'type' => 'g6-nanode-1',
'watchdog_enabled' => true,
'tags' => ['linode-sdk', 'test'],
Expand All @@ -30,7 +30,7 @@
dataset('instance-clone', [
fn () => [
'authorized_keys' => ['ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCo0z7DrPhlm6xFaexs+OhpVII3U3B36F6S/kmRlXGUeRkNOc4okmR8POAHAcctRM2c0kyDbhbX7E52efyEHvOCfvpjA23SIM+bxn0Do3az2lLZZQ3EDjgjkANHXPh4zOSPTYKMAivsT6JY521bQwDXa6oqrG36/wuJhHZWJLaCoq86KYpm2smcKe2W+5f/GWwXNNGBAqCfVA3MK0RbnTdyUL0AUJz3V+wLUAqqf3rSLJmthiKfvexxY1b9srhyM/V2R4zUplZgOl5FkQ8NVbHGSCHTx8q8vdDqMGTx1tdbvuiWsXnIIFoJHE4ZY7LVAbm+VoXmeiNpzn14xWNSM7hWh0AwAlZPviTVFAR+htffc45g2fIF9XDcvDFbCQBv3GpYMgcxMeE1IC4oLDbOhmDUgyonooY9ginmFM5HiVU8AaIKMqpBlX+618YHWD1GF2qL1IfQKiQXp+UvLHYOY9XpTjPyUw+Ku9BqCDiQma+ROhi39aAd/ZAWS5FOu3/s6Bk='],
'authorized_users' => ['mwangithegreat'],
'authorized_users' => ['test'],
'region' => 'eu-west',
'image' => 'linode/ubuntu20.04',
'private_ip' => true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"statusCode":401,"headers":{"Server":"nginx","Date":"Tue, 04 Jul 2023 08:37:09 GMT","Content-Type":"application\/json","Content-Length":"41","Connection":"keep-alive","X-OAuth-Scopes":"unknown","X-Accepted-OAuth-Scopes":"linodes:read_write","X-Frame-Options":"DENY","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"HEAD, GET, OPTIONS, POST, PUT, DELETE","Access-Control-Allow-Headers":"Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter","X-Spec-Version":"4.157.1","X-RateLimit-Limit":"800","X-RateLimit-Remaining":"797","X-RateLimit-Reset":"1688459878","Retry-After":"48"},"data":"{\"errors\": [{\"reason\": \"Invalid Token\"}]}"}
{"statusCode":200,"headers":{"Content-Type":"application\/json","Content-Length":"2","X-OAuth-Scopes":"*","X-Accepted-OAuth-Scopes":"linodes:read_write","X-Frame-Options":["DENY","DENY"],"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"HEAD, GET, OPTIONS, POST, PUT, DELETE","Access-Control-Allow-Headers":"Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter","X-Spec-Version":"4.171.0","X-Customer-UUID":"D09103B1-FFFF-AAAA-B88C000000000004","X-RateLimit-Limit":"400","X-RateLimit-Remaining":"399","X-RateLimit-Reset":"1706644595","Retry-After":"60","Access-Control-Allow-Credentials":"true","Access-Control-Expose-Headers":"X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status","Content-Security-Policy":"default-src 'none'","Vary":"Authorization, X-Filter","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Strict-Transport-Security":"max-age=31536000","Expires":"Tue, 30 Jan 2024 19:55:34 GMT","Cache-Control":"max-age=0, no-cache, no-store","Pragma":"no-cache","Date":"Tue, 30 Jan 2024 19:55:34 GMT","Connection":"keep-alive"},"data":"{}"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"statusCode":401,"headers":{"Server":"nginx","Date":"Tue, 04 Jul 2023 08:37:15 GMT","Content-Type":"application\/json","Content-Length":"41","Connection":"keep-alive","X-OAuth-Scopes":"unknown","X-Accepted-OAuth-Scopes":"firewall:read_write","X-Frame-Options":"DENY","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"HEAD, GET, OPTIONS, POST, PUT, DELETE","Access-Control-Allow-Headers":"Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter","X-Spec-Version":"4.157.1","X-RateLimit-Limit":"800","X-RateLimit-Remaining":"797","X-RateLimit-Reset":"1688459879","Retry-After":"43"},"data":"{\"errors\": [{\"reason\": \"Invalid Token\"}]}"}
{"statusCode":200,"headers":{"Content-Type":"application\/json","Content-Length":"2","X-OAuth-Scopes":"*","X-Accepted-OAuth-Scopes":"firewall:read_write","X-Frame-Options":["DENY","DENY"],"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"HEAD, GET, OPTIONS, POST, PUT, DELETE","Access-Control-Allow-Headers":"Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter","X-Spec-Version":"4.171.0","X-Customer-UUID":"D09103B1-FFFF-AAAA-B88C000000000004","X-RateLimit-Limit":"400","X-RateLimit-Remaining":"398","X-RateLimit-Reset":"1706631790","Retry-After":"0","Access-Control-Allow-Credentials":"true","Access-Control-Expose-Headers":"X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status","Content-Security-Policy":"default-src 'none'","Vary":"Authorization, X-Filter","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Strict-Transport-Security":"max-age=31536000","Expires":"Tue, 30 Jan 2024 16:23:09 GMT","Cache-Control":"max-age=0, no-cache, no-store","Pragma":"no-cache","Date":"Tue, 30 Jan 2024 16:23:09 GMT","Connection":"keep-alive"},"data":"{}"}
39 changes: 38 additions & 1 deletion tests/Fixtures/Saloon/get/account.json
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
{"statusCode":401,"headers":{"Server":"nginx","Date":"Mon, 03 Jul 2023 13:13:06 GMT","Content-Type":"application\/json","Content-Length":"41","Connection":"keep-alive","Cache-Control":"private, max-age=0, s-maxage=0, no-cache, no-store","X-OAuth-Scopes":"unknown","X-Accepted-OAuth-Scopes":"account:read_only","X-Frame-Options":"DENY","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"HEAD, GET, OPTIONS, POST, PUT, DELETE","Access-Control-Allow-Headers":"Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter","X-Spec-Version":"4.157.1","Vary":"Authorization, X-Filter","X-RateLimit-Limit":"800","X-RateLimit-Remaining":"799","X-RateLimit-Reset":"1688390047","Retry-After":"60"},"data":"{\"errors\": [{\"reason\": \"Invalid Token\"}]}"}
{
"statusCode": 200,
"headers": {
"Content-Type": "application\/json",
"Content-Length": "680",
"X-OAuth-Scopes": "*",
"X-Accepted-OAuth-Scopes": "account:read_only",
"X-Frame-Options": [
"DENY",
"DENY"
],
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "HEAD, GET, OPTIONS, POST, PUT, DELETE",
"Access-Control-Allow-Headers": "Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter",
"X-Spec-Version": "4.171.0",
"Vary": [
"Authorization, X-Filter",
"Authorization, X-Filter"
],
"X-Customer-UUID": "D09103B1-FFFF-AAAA-B88C000000000004",
"X-RateLimit-Limit": "400",
"X-RateLimit-Remaining": "399",
"X-RateLimit-Reset": "1706632201",
"Retry-After": "60",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Expose-Headers": "X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status",
"Content-Security-Policy": "default-src 'none'",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Strict-Transport-Security": "max-age=31536000",
"Expires": "Tue, 30 Jan 2024 16:29:01 GMT",
"Cache-Control": "max-age=0, no-cache, no-store",
"Pragma": "no-cache",
"Date": "Tue, 30 Jan 2024 16:29:01 GMT",
"Connection": "keep-alive"
},
"data": "{\"company\": \"Test Company Unlimited\", \"email\": \"[email protected]\", \"first_name\": \"Samuel\", \"last_name\": \"Mwangi\", \"address_1\": \"P.O Box 123\", \"address_2\": \"\", \"city\": \"Nairobi\", \"state\": \"Nairobi City\", \"zip\": \"00100\", \"country\": \"KE\", \"phone\": \"\", \"balance\": 1000.0, \"tax_id\": \"\", \"billing_source\": \"linode\", \"credit_card\": {\"last_four\": \"1234\", \"expiry\": \"05\/2038\"}, \"balance_uninvoiced\": 0.09, \"active_since\": \"2007-08-19T09:18:33\", \"capabilities\": [\"Linodes\", \"NodeBalancers\", \"Block Storage\", \"Object Storage\", \"Kubernetes\", \"Cloud Firewall\", \"Vlans\", \"LKE HA Control Planes\", \"Machine Images\", \"VPCs\"], \"active_promotions\": [], \"euuid\": \"D09103B1-FFFF-AAAA-B88C000000000004\"}"
}
Loading

0 comments on commit 6c3d019

Please sign in to comment.