Skip to content

Commit 16cae5f

Browse files
committed
Merge branch 'hotfix/0.2.0'
2 parents 96a1b14 + e9047b8 commit 16cae5f

File tree

5 files changed

+61
-26
lines changed

5 files changed

+61
-26
lines changed

.github/workflows/ci-cd.yml

+44-13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,37 @@ on:
1111
- '[0-9]+.[0-9]+.[0-9]+-[a-z]+'
1212
- '[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+'
1313
jobs:
14+
lint:
15+
name: Linter Test
16+
runs-on: ubuntu-latest
17+
container:
18+
image: pipelinecomponents/flake8
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Lint with flake8
25+
run: flake8
26+
jar:
27+
name: Get Jar File
28+
if:
29+
github.ref_type == 'tag' ||
30+
github.event_name == 'pull_request' ||
31+
contains('refs/heads/main refs/heads/develop', github.ref) ||
32+
startsWith(github.ref, 'refs/heads/release/') ||
33+
startsWith(github.ref, 'refs/heads/hotfix/')
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Cache jar
37+
id: cache-java-jar
38+
uses: actions/cache@v3
39+
with:
40+
path: app/asicverifier.jar
41+
key: java-jar
42+
- name: Get jar file from docker
43+
if: steps.cache-java-jar.outputs.cache-hit != 'true'
44+
run: docker run --rm --platform linux/amd64 -v $PWD/app/:/app/ --entrypoint cp niis/xroad-security-server-sidecar:7.0.4 /usr/share/xroad/jlib/asicverifier.jar app/asicverifier.jar
1445
venv:
1546
name: Virtual environment
1647
if:
@@ -39,21 +70,9 @@ jobs:
3970
. venv/bin/activate
4071
pip install --upgrade pip
4172
pip install build 'coverage[toml]' httpx
42-
lint:
43-
name: Linter Test
44-
runs-on: ubuntu-latest
45-
container:
46-
image: pipelinecomponents/flake8
47-
steps:
48-
- name: Checkout
49-
uses: actions/checkout@v4
50-
with:
51-
fetch-depth: 0
52-
- name: Lint with flake8
53-
run: flake8
5473
unittest:
5574
name: Unit Test
56-
needs: venv
75+
needs: [jar, venv]
5776
runs-on: ubuntu-latest
5877
steps:
5978
- name: Checkout
@@ -71,7 +90,19 @@ jobs:
7190
echo PATH=$PATH >> $GITHUB_ENV
7291
- name: Install package
7392
run: pip install '.[restful-api]'
93+
- name: Set up Java
94+
uses: actions/setup-java@v3
95+
with:
96+
distribution: temurin
97+
java-version: '8'
98+
- name: Cache jar
99+
uses: actions/cache@v3
100+
with:
101+
path: app/asicverifier.jar
102+
key: java-jar
74103
- name: Test
104+
env:
105+
JAR_PATH: app/asicverifier.jar
75106
run: python -m coverage run -m unittest
76107
- name: Display test coverage
77108
run: python -m coverage report -m

asicverifier/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# This module is part of AsicVerifier and is released under
44
# the AGPL-3.0-only License: https://opensource.org/license/agpl-v3/
55

6+
from dateutil import tz
7+
from dateutil.parser import parse
68
from datetime import datetime
79
from enum import Enum
810
from io import BytesIO
@@ -25,7 +27,7 @@
2527

2628

2729
def to_datetime(string: str) -> datetime:
28-
return datetime.strptime(string, r'%a %b %d %H:%M:%S %Z %Y')
30+
return parse(string, tzinfos={'WIB': tz.gettz('Asia/Jakarta')})
2931

3032

3133
def extract_subject_or_issuer(message: str) -> dict:

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ classifiers = [
2626
'Topic :: Text Processing',
2727
'Topic :: Utilities'
2828
]
29-
dependencies = ['python-dotenv', 'typer[all]', 'requests']
29+
dependencies = ['python-dotenv', 'typer[all]', 'requests', 'python-dateutil']
3030
scripts = { asicverifier = 'asicverifier.__main__:cli' }
3131
dynamic = ['version']
3232

tests/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# This module is part of AsicVerifier and is released under
44
# the AGPL-3.0-only License: https://opensource.org/license/agpl-v3/
55

6+
from dateutil.parser import parse
7+
from dateutil.tz import tzutc
68
from datetime import datetime
79
import json
810
import unittest
@@ -34,11 +36,11 @@
3436
DIRS: str = 'tests/data/'
3537

3638

37-
def datetime_parser(data: dict, format: str = r'%Y-%m-%dT%H:%M:%S') -> dict:
39+
def datetime_parser(data: dict) -> dict:
3840
for key, value in data.items():
3941
if isinstance(value, str):
4042
try:
41-
data[key] = datetime.strptime(value, format)
43+
data[key] = parse(value)
4244
except ValueError:
4345
pass
4446

@@ -106,7 +108,7 @@ def test_main(self):
106108
def test_to_datetime(self):
107109
self.assertEqual(
108110
to_datetime('Mon May 29 08:33:50 GMT 2023'),
109-
datetime(2023, 5, 29, 8, 33, 50)
111+
datetime(2023, 5, 29, 8, 33, 50, tzinfo=tzutc())
110112
)
111113

112114
def test_extract_subject_or_issuer(self):

tests/data/asicverifier.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
},
1414
"serial_number": 13,
1515
"valid": {
16-
"from": "2023-05-29T15:33:50",
17-
"until": "2043-05-24T15:33:50"
16+
"from": "2023-05-29T15:33:50+07:00",
17+
"until": "2043-05-24T15:33:50+07:00"
1818
}
1919
},
2020
"id": {
@@ -33,11 +33,11 @@
3333
},
3434
"serial_number": 1,
3535
"valid": {
36-
"from": "2023-05-23T04:08:07",
37-
"until": "2043-05-18T04:08:07"
36+
"from": "2023-05-23T04:08:07+07:00",
37+
"until": "2043-05-18T04:08:07+07:00"
3838
}
3939
},
40-
"produced_at": "2023-10-02T09:44:28"
40+
"produced_at": "2023-10-02T09:44:28+07:00"
4141
},
4242
"timestamp": {
4343
"signed_by": {
@@ -62,11 +62,11 @@
6262
},
6363
"serial_number": 13972846748170250626,
6464
"valid": {
65-
"from": "2016-03-13T08:57:39",
66-
"until": "2026-03-11T08:57:39"
65+
"from": "2016-03-13T08:57:39+07:00",
66+
"until": "2026-03-11T08:57:39+07:00"
6767
}
6868
},
69-
"date": "2023-10-02T10:02:03"
69+
"date": "2023-10-02T10:02:03+07:00"
7070
},
7171
"file": [
7272
{

0 commit comments

Comments
 (0)