Skip to content

Commit 6954c83

Browse files
Merge branch 'dev' into TPT-3261-custom-aliases
2 parents 1cbc4b2 + 5612fe9 commit 6954c83

File tree

6 files changed

+437
-248
lines changed

6 files changed

+437
-248
lines changed

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@v4
2222
-
2323
name: Run Labeler
24-
uses: crazy-max/ghaction-github-labeler@31674a3852a9074f2086abcf1c53839d466a47e7
24+
uses: crazy-max/ghaction-github-labeler@24d110aa46a59976b8a7f35518cb7f14f434c916
2525
with:
2626
github-token: ${{ secrets.GITHUB_TOKEN }}
2727
yaml-file: .github/labels.yml

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # [email protected]
4646

4747
- name: Login to Docker Hub
48-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pin@v3.3.0
48+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # pin@v3.4.0
4949
with:
5050
username: ${{ secrets.DOCKERHUB_USERNAME }}
5151
password: ${{ secrets.DOCKERHUB_TOKEN }}

tests/integration/obj/conftest.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import json
2+
from dataclasses import dataclass
3+
from typing import Callable, Optional
4+
5+
import pytest
6+
from pytest import MonkeyPatch
7+
8+
from linodecli.plugins.obj import ENV_ACCESS_KEY_NAME, ENV_SECRET_KEY_NAME
9+
from tests.integration.helpers import exec_test_command, get_random_text
10+
11+
REGION = "us-southeast-1"
12+
CLI_CMD = ["linode-cli", "object-storage"]
13+
BASE_CMD = ["linode-cli", "obj", "--cluster", REGION]
14+
15+
16+
@dataclass
17+
class Keys:
18+
access_key: str
19+
secret_key: str
20+
21+
22+
def patch_keys(keys: Keys, monkeypatch: MonkeyPatch):
23+
assert keys.access_key is not None
24+
assert keys.secret_key is not None
25+
monkeypatch.setenv(ENV_ACCESS_KEY_NAME, keys.access_key)
26+
monkeypatch.setenv(ENV_SECRET_KEY_NAME, keys.secret_key)
27+
28+
29+
def delete_bucket(bucket_name: str, force: bool = True):
30+
args = BASE_CMD + ["rb", bucket_name]
31+
if force:
32+
args.append("--recursive")
33+
exec_test_command(args)
34+
return bucket_name
35+
36+
37+
@pytest.fixture
38+
def create_bucket(
39+
name_generator: Callable, keys: Keys, monkeypatch: MonkeyPatch
40+
):
41+
created_buckets = set()
42+
patch_keys(keys, monkeypatch)
43+
44+
def _create_bucket(bucket_name: Optional[str] = None):
45+
if not bucket_name:
46+
bucket_name = name_generator("test-bk")
47+
48+
exec_test_command(BASE_CMD + ["mb", bucket_name])
49+
created_buckets.add(bucket_name)
50+
return bucket_name
51+
52+
yield _create_bucket
53+
for bk in created_buckets:
54+
try:
55+
delete_bucket(bk)
56+
except Exception as e:
57+
logging.exception(f"Failed to cleanup bucket: {bk}, {e}")
58+
59+
60+
@pytest.fixture
61+
def static_site_index():
62+
return (
63+
"<!DOCTYPE html>"
64+
"<html><head>"
65+
"<title>Hello World</title>"
66+
"</head><body>"
67+
"<p>Hello, World!</p>"
68+
"</body></html>"
69+
)
70+
71+
72+
@pytest.fixture
73+
def static_site_error():
74+
return (
75+
"<!DOCTYPE html>"
76+
"<html><head>"
77+
"<title>Error</title>"
78+
"</head><body>"
79+
"<p>Error!</p>"
80+
"</body></html>"
81+
)
82+
83+
84+
@pytest.fixture(scope="session")
85+
def keys():
86+
response = json.loads(
87+
exec_test_command(
88+
CLI_CMD
89+
+ [
90+
"keys-create",
91+
"--label",
92+
"cli-integration-test-obj-key",
93+
"--json",
94+
],
95+
).stdout.decode()
96+
)[0]
97+
_keys = Keys(
98+
access_key=response.get("access_key"),
99+
secret_key=response.get("secret_key"),
100+
)
101+
yield _keys
102+
exec_test_command(CLI_CMD + ["keys-delete", str(response.get("id"))])
103+
104+
105+
@pytest.fixture(scope="session")
106+
def test_key():
107+
label = get_random_text(10)
108+
key = (
109+
exec_test_command(
110+
CLI_CMD
111+
+ [
112+
"keys-create",
113+
"--label",
114+
label,
115+
"--text",
116+
"--no-headers",
117+
"--format=id",
118+
]
119+
)
120+
.stdout.decode()
121+
.strip()
122+
)
123+
124+
yield key
125+
126+
exec_test_command(CLI_CMD + ["keys-delete", key])

tests/integration/obj/test_obj_bucket.py

Lines changed: 0 additions & 148 deletions
This file was deleted.

0 commit comments

Comments
 (0)