Skip to content

Commit 8561740

Browse files
authored
Techdebt: Remove ACM/pytest warnings (#7350)
1 parent 4b89874 commit 8561740

13 files changed

Lines changed: 51 additions & 37 deletions

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
2323
- name: pip cache
2424
id: pip-cache
25-
uses: actions/cache@v3
25+
uses: actions/cache@v4
2626
with:
2727
path: ${{ steps.pip-cache-dir.outputs.dir }}
2828
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}
@@ -55,7 +55,7 @@ jobs:
5555
run: |
5656
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
5757
- name: pip cache
58-
uses: actions/cache@v3
58+
uses: actions/cache@v4
5959
with:
6060
path: ${{ steps.pip-cache.outputs.dir }}
6161
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}

.github/workflows/dockertests.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
2323
- name: pip cache
2424
id: pip-cache
25-
uses: actions/cache@v3
25+
uses: actions/cache@v4
2626
with:
2727
path: ${{ steps.pip-cache-dir.outputs.dir }}
2828
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}
@@ -62,7 +62,7 @@ jobs:
6262
run: |
6363
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
6464
- name: pip cache
65-
uses: actions/cache@v3
65+
uses: actions/cache@v4
6666
with:
6767
path: ${{ steps.pip-cache.outputs.dir }}
6868
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}
@@ -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
@@ -122,7 +120,7 @@ jobs:
122120
run: |
123121
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
124122
- name: pip cache
125-
uses: actions/cache@v3
123+
uses: actions/cache@v4
126124
with:
127125
path: ${{ steps.pip-cache.outputs.dir }}
128126
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}
@@ -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()
@@ -179,7 +175,7 @@ jobs:
179175
run: |
180176
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
181177
- name: pip cache
182-
uses: actions/cache@v3
178+
uses: actions/cache@v4
183179
with:
184180
path: ${{ steps.pip-cache.outputs.dir }}
185181
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}
@@ -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_decoratormode.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: |
2323
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
2424
- name: pip cache
25-
uses: actions/cache@v3
25+
uses: actions/cache@v4
2626
with:
2727
path: ${{ steps.pip-cache.outputs.dir }}
2828
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}

.github/workflows/tests_proxymode.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: |
2323
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
2424
- name: pip cache
25-
uses: actions/cache@v3
25+
uses: actions/cache@v4
2626
with:
2727
path: ${{ steps.pip-cache.outputs.dir }}
2828
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}
@@ -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_real_aws.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: |
2424
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
2525
- name: pip cache
26-
uses: actions/cache@v3
26+
uses: actions/cache@v4
2727
with:
2828
path: ${{ steps.pip-cache.outputs.dir }}
2929
key: pip-3.11-${{ hashFiles('**/setup.cfg') }}

.github/workflows/tests_sdk_dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
docker run --rm -t --name motoserver -e TEST_SERVER_MODE=true -e AWS_SECRET_ACCESS_KEY=server_secret -e AWS_ACCESS_KEY_ID=server_key -v `pwd`:/moto -p 5000:5000 -v /var/run/docker.sock:/var/run/docker.sock python:3.10-slim /moto/scripts/ci_moto_server.sh &
2121
python scripts/ci_wait_for_server.py
2222
- uses: actions/setup-dotnet@v4
23-
- uses: actions/cache@v3
23+
- uses: actions/cache@v4
2424
with:
2525
path: ~/.nuget/packages
2626
# Look to see if there is a cache hit for the corresponding requirements file

.github/workflows/tests_servermode.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: |
2929
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
3030
- name: pip cache
31-
uses: actions/cache@v3
31+
uses: actions/cache@v4
3232
with:
3333
path: ${{ steps.pip-cache.outputs.dir }}
3434
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.cfg') }}
@@ -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]

0 commit comments

Comments
 (0)