|
26 | 26 | from botocore.client import BaseClient |
27 | 27 | from botocore.exceptions import ClientError |
28 | 28 |
|
29 | | -# Configure endpoint - default to docker service name |
30 | | -ENDPOINT_URL = os.environ.get("AWS_ENDPOINT_URL", "http://ruststack:4566") |
| 29 | +# Configure endpoint - default to local process |
| 30 | +ENDPOINT_URL = os.environ.get("AWS_ENDPOINT_URL", "http://localhost:4566") |
31 | 31 | REGION = "us-east-1" |
32 | 32 |
|
| 33 | +# Set dummy credentials for boto3 if not already in environment |
| 34 | +os.environ.setdefault("AWS_ACCESS_KEY_ID", "test") |
| 35 | +os.environ.setdefault("AWS_SECRET_ACCESS_KEY", "test") |
| 36 | + |
33 | 37 |
|
34 | 38 | class TestRustStackHealth: |
35 | 39 | """Basic health check tests.""" |
@@ -206,28 +210,43 @@ def test_list_objects_pagination(self, client): |
206 | 210 | client.put_object(Bucket=bucket_name, Key=f"file{i:04d}.txt", Body=f"content {i}") |
207 | 211 |
|
208 | 212 | # First request with small max-keys |
209 | | - result = client.list_objects_v2(Bucket=bucket_name, MaxKeys=10) |
| 213 | + result = client.list_objects_v2(Bucket=bucket_name, MaxKeys=15) |
210 | 214 |
|
211 | | - assert len(result["Contents"]) == 10 |
| 215 | + assert len(result["Contents"]) == 15 |
212 | 216 | assert result["IsTruncated"] is True |
213 | 217 | assert "NextContinuationToken" in result |
214 | 218 |
|
215 | | - # Second request with continuation token - should get more objects |
| 219 | + # Second request with continuation token |
216 | 220 | token = result["NextContinuationToken"] |
217 | | - result2 = client.list_objects_v2(Bucket=bucket_name, ContinuationToken=token) |
| 221 | + result2 = client.list_objects_v2(Bucket=bucket_name, ContinuationToken=token, MaxKeys=15) |
| 222 | + |
| 223 | + assert len(result2["Contents"]) == 15 |
| 224 | + assert result2["IsTruncated"] is True |
| 225 | + assert "NextContinuationToken" in result2 |
| 226 | + |
| 227 | + # Third request |
| 228 | + token2 = result2["NextContinuationToken"] |
| 229 | + result3 = client.list_objects_v2(Bucket=bucket_name, ContinuationToken=token2, MaxKeys=15) |
| 230 | + |
| 231 | + assert len(result3["Contents"]) == 15 |
| 232 | + assert result3["IsTruncated"] is True |
| 233 | + |
| 234 | + # Fourth request - should get remaining 5 |
| 235 | + token3 = result3["NextContinuationToken"] |
| 236 | + result4 = client.list_objects_v2(Bucket=bucket_name, ContinuationToken=token3, MaxKeys=15) |
218 | 237 |
|
219 | | - # Should have some objects (at least some from the remaining 40) |
220 | | - assert len(result2["Contents"]) > 0 |
221 | | - assert len(result2["Contents"]) < 50 |
| 238 | + assert len(result4["Contents"]) == 5 |
| 239 | + assert result4["IsTruncated"] is False |
| 240 | + assert "NextContinuationToken" not in result4 |
222 | 241 |
|
223 | 242 | # Verify all objects can be retrieved by continuing |
224 | 243 | all_keys = [] |
225 | 244 | token = None |
226 | 245 | while True: |
227 | 246 | if token: |
228 | | - result = client.list_objects_v2(Bucket=bucket_name, ContinuationToken=token) |
| 247 | + result = client.list_objects_v2(Bucket=bucket_name, ContinuationToken=token, MaxKeys=20) |
229 | 248 | else: |
230 | | - result = client.list_objects_v2(Bucket=bucket_name) |
| 249 | + result = client.list_objects_v2(Bucket=bucket_name, MaxKeys=20) |
231 | 250 |
|
232 | 251 | all_keys.extend([obj["Key"] for obj in result.get("Contents", [])]) |
233 | 252 |
|
|
0 commit comments