|
1 | 1 | import ipaddress |
| 2 | +import random |
2 | 3 | import time |
3 | 4 | from test.integration.conftest import get_region |
4 | 5 | from test.integration.helpers import ( |
@@ -234,6 +235,28 @@ def linode_with_disk_encryption(test_linode_client, request): |
234 | 235 | linode_instance.delete() |
235 | 236 |
|
236 | 237 |
|
| 238 | +@pytest.fixture(scope="session") |
| 239 | +def create_linode_with_authorization_key(test_linode_client, e2e_test_firewall): |
| 240 | + client = test_linode_client |
| 241 | + |
| 242 | + region = get_region(client, {"Linodes", "Cloud Firewall"}, site_type="core") |
| 243 | + label = get_test_label(length=8) |
| 244 | + |
| 245 | + linode_instance = client.linode.instance_create( |
| 246 | + "g6-nanode-1", |
| 247 | + region, |
| 248 | + image="linode/debian12", |
| 249 | + label=label, |
| 250 | + kernel="linode/6.15.7-x86_64-linode169", |
| 251 | + boot_size=9000, |
| 252 | + authorized_keys="ssh-rsa", |
| 253 | + ) |
| 254 | + |
| 255 | + yield linode_instance |
| 256 | + |
| 257 | + linode_instance.delete() |
| 258 | + |
| 259 | + |
237 | 260 | # Test helper |
238 | 261 | def get_status(linode: Instance, status: str): |
239 | 262 | return linode.status == status |
@@ -1159,3 +1182,54 @@ def test_update_linode_maintenance_policy(create_linode, test_linode_client): |
1159 | 1182 | linode.invalidate() |
1160 | 1183 | assert result |
1161 | 1184 | assert linode.maintenance_policy_id == non_default_policy.slug |
| 1185 | + |
| 1186 | + |
| 1187 | +def test_expected_error_if_fields_authorized_users_authorized_keys_root_pass_are_not_set( |
| 1188 | + test_linode_client, |
| 1189 | +): |
| 1190 | + client = test_linode_client |
| 1191 | + region = get_region(client, {"Linodes", "Cloud Firewall"}, site_type="core") |
| 1192 | + label = get_test_label(length=8) |
| 1193 | + |
| 1194 | + with pytest.raises(ValueError) as create_instance_error: |
| 1195 | + client.linode.instance_create( |
| 1196 | + "g6-nanode-1", |
| 1197 | + region, |
| 1198 | + image="linode/debian12", |
| 1199 | + label=label, |
| 1200 | + kernel="linode/6.15.7-x86_64-linode169", |
| 1201 | + boot_size="9000", |
| 1202 | + ) |
| 1203 | + assert ( |
| 1204 | + "When creating an Instance from an Image, at least one of root_pass, authorized_users, or authorized_keys must be provided." |
| 1205 | + in str(create_instance_error.value) |
| 1206 | + ) |
| 1207 | + |
| 1208 | + |
| 1209 | +def test_create_linode_with_kernel_and_boot_size_then_add_disk_and_rebuild( |
| 1210 | + create_linode_with_authorization_key, |
| 1211 | +): |
| 1212 | + linode_create = create_linode_with_authorization_key |
| 1213 | + assert linode_create.image.id == "linode/debian12" |
| 1214 | + |
| 1215 | + wait_for_condition(10, 300, get_status, linode_create, "running") |
| 1216 | + disk_create = send_request_when_resource_available( |
| 1217 | + 300, |
| 1218 | + linode_create.disk_create, |
| 1219 | + size=2000, |
| 1220 | + image="linode/debian12", |
| 1221 | + label="python-disk-test-" + random.randrange(100000, 999999).__str__(), |
| 1222 | + root_pass="aComplex@Password123", |
| 1223 | + ) |
| 1224 | + wait_for_disk_status(disk_create, 120) |
| 1225 | + assert disk_create.status == "ready" |
| 1226 | + |
| 1227 | + retry_sending_request( |
| 1228 | + 3, |
| 1229 | + linode_create.rebuild, |
| 1230 | + "linode/debian12", |
| 1231 | + authorized_keys="ecdsa-sha2-nistp", |
| 1232 | + ) |
| 1233 | + wait_for_condition(10, 300, get_status, linode_create, "rebuilding") |
| 1234 | + assert linode_create.status == "rebuilding" |
| 1235 | + assert linode_create.image.id == "linode/debian12" |
0 commit comments