Skip to content

Commit d88001c

Browse files
committed
Techdebt: Remove warnings
1 parent 4b89874 commit d88001c

8 files changed

Lines changed: 37 additions & 26 deletions

File tree

.github/workflows/dockertests.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ jobs:
8282
if: always()
8383
run: |
8484
mkdir serverlogs1
85-
pwd
86-
ls -la
8785
cp server_output.log serverlogs1/server_output.log
8886
docker stop motoserver
8987
- name: Archive Logs
@@ -141,8 +139,6 @@ jobs:
141139
if: always()
142140
run: |
143141
mkdir serverlogs2
144-
pwd
145-
ls -la
146142
cp server_output.log serverlogs2/server_output.log
147143
- name: Archive logs
148144
if: always()
@@ -200,10 +196,7 @@ jobs:
200196
if: always()
201197
run: |
202198
mkdir serverlogs3
203-
pwd
204-
ls -la
205199
cp server_output.log serverlogs3/server_output.log
206-
ls -la serverlogs3
207200
- name: Archive Logs
208201
if: always()
209202
uses: actions/upload-artifact@v4

.github/workflows/test_outdated_versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
responses-version: ["0.15.0", "0.17.0", "0.19.0", "0.20.0" ]
1919
werkzeug-version: ["2.0.1", "2.1.1", "2.2.2"]
2020
openapi-spec-validator-version: ["0.5.0"]
21+
cryptography-version: ["39.0.0"]
2122

2223
steps:
2324
- name: Checkout repository
@@ -40,6 +41,7 @@ jobs:
4041
pip install werkzeug==${{ matrix.werkzeug-version }}
4142
pip install openapi-spec-validator==${{ matrix.openapi-spec-validator-version }}
4243
pip install ${{ matrix.botocore }}
44+
pip install cryptography==${{ matrix.cryptography-version }}
4345
4446
- name: Run tests
4547
run: |
@@ -59,8 +61,6 @@ jobs:
5961
if: always()
6062
run: |
6163
mkdir serverlogs
62-
pwd
63-
ls -la
6464
cp server_output.log serverlogs/server_output.log
6565
docker stop motoserver
6666
- name: Archive TF logs

.github/workflows/tests_proxymode.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ jobs:
4545
- name: "Stop MotoProxy"
4646
if: always()
4747
run: |
48-
pwd
49-
ls -la
5048
kill $(lsof -t -i:5005)
5149
- name: Archive Proxy logs
5250
if: always()

.github/workflows/tests_servermode.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ jobs:
6060
if: always()
6161
run: |
6262
mkdir serverlogs
63-
pwd
64-
ls -la
6563
cp server_output.log serverlogs/server_output.log
6664
docker stop motoserver
6765
- name: Archive TF logs

moto/acm/models.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ def validate_certificate(self) -> cryptography.x509.base.Certificate:
238238
)
239239

240240
now = utcnow()
241-
if _cert.not_valid_after < now:
241+
if self._not_valid_after(_cert) < now:
242242
raise AWSValidationException(
243243
"The certificate has expired, is not valid."
244244
)
245245

246-
if _cert.not_valid_before > now:
246+
if self._not_valid_before(_cert) > now:
247247
raise AWSValidationException(
248248
"The certificate is not in effect yet, is not valid."
249249
)
@@ -256,6 +256,22 @@ def validate_certificate(self) -> cryptography.x509.base.Certificate:
256256
)
257257
return _cert
258258

259+
def _not_valid_after(
260+
self, _cert: cryptography.x509.base.Certificate
261+
) -> datetime.datetime:
262+
try:
263+
return _cert.not_valid_after_utc.replace(tzinfo=None)
264+
except AttributeError:
265+
return _cert.not_valid_after
266+
267+
def _not_valid_before(
268+
self, _cert: cryptography.x509.base.Certificate
269+
) -> datetime.datetime:
270+
try:
271+
return _cert.not_valid_before_utc.replace(tzinfo=None)
272+
except AttributeError:
273+
return _cert.not_valid_before
274+
259275
def validate_chain(self) -> None:
260276
try:
261277
for cert_armored in self.chain.split(b"-\n-"):
@@ -267,12 +283,12 @@ def validate_chain(self) -> None:
267283
)
268284

269285
now = utcnow()
270-
if self._cert.not_valid_after < now:
286+
if self._not_valid_after(self._cert) < now:
271287
raise AWSValidationException(
272288
"The certificate chain has expired, is not valid."
273289
)
274290

275-
if self._cert.not_valid_before > now:
291+
if self._not_valid_before(self._cert) > now:
276292
raise AWSValidationException(
277293
"The certificate chain is not in effect yet, is not valid."
278294
)
@@ -325,8 +341,8 @@ def describe(self) -> Dict[str, Any]:
325341
0
326342
].value,
327343
"KeyAlgorithm": key_algo,
328-
"NotAfter": datetime_to_epoch(self._cert.not_valid_after),
329-
"NotBefore": datetime_to_epoch(self._cert.not_valid_before),
344+
"NotAfter": datetime_to_epoch(self._not_valid_after(self._cert)),
345+
"NotBefore": datetime_to_epoch(self._not_valid_before(self._cert)),
330346
"Serial": str(self._cert.serial_number),
331347
"SignatureAlgorithm": self._cert.signature_algorithm_oid._name.upper().replace(
332348
"ENCRYPTION", ""

moto/acmpca/models.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,19 @@ def certificate_bytes(self) -> bytes:
149149
def not_valid_after(self) -> Optional[float]:
150150
if self.certificate is None:
151151
return None
152-
return unix_time(self.certificate.not_valid_after)
152+
try:
153+
return unix_time(self.certificate.not_valid_after_utc.replace(tzinfo=None))
154+
except AttributeError:
155+
return unix_time(self.certificate.not_valid_after)
153156

154157
@property
155158
def not_valid_before(self) -> Optional[float]:
156159
if self.certificate is None:
157160
return None
158-
return unix_time(self.certificate.not_valid_before)
161+
try:
162+
return unix_time(self.certificate.not_valid_before_utc.replace(tzinfo=None))
163+
except AttributeError:
164+
return unix_time(self.certificate.not_valid_before)
159165

160166
def import_certificate_authority_certificate(
161167
self, certificate: bytes, certificate_chain: Optional[bytes]

tests/test_core/test_mypy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66

77
@mock_aws
8-
def test_without_parentheses() -> int:
8+
def method_without_parentheses() -> int:
99
assert boto3.client("s3").list_buckets()["Buckets"] == []
1010
return 123
1111

1212

1313
@mock_aws()
14-
def test_with_parentheses() -> int:
14+
def method_with_parentheses() -> int:
1515
assert boto3.client("s3").list_buckets()["Buckets"] == []
1616
return 456
1717

@@ -35,8 +35,8 @@ def test_manual() -> None:
3535
m.stop()
3636

3737

38-
x: int = test_with_parentheses()
38+
x: int = method_with_parentheses()
3939
assert x == 456
4040

41-
y: int = test_without_parentheses()
41+
y: int = method_without_parentheses()
4242
assert y == 123

tests/test_ec2/test_route_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ def test_create_route_with_vpc_endpoint():
10581058
VpcEndpointId=vpce_id,
10591059
RouteTableId=route_table.id,
10601060
)
1061-
rt = ec2_client.describe_route_tables()
1061+
rt = ec2_client.describe_route_tables(RouteTableIds=[route_table.id])
10621062
new_route = rt["RouteTables"][-1]["Routes"][1]
10631063

10641064
# Verify

0 commit comments

Comments
 (0)