Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/package
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Creates a package for Testrun

MAKE_SRC_DIR=make
TESTRUN_VER="1-2-2"
TESTRUN_VER="1-3-alpha"

# Delete existing make files
rm -rf $MAKE_SRC_DIR/usr
Expand Down
9 changes: 6 additions & 3 deletions framework/python/src/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,12 @@ async def upload_cert(self,
# Get file contents
contents = await file.read()

# Pass to session to check and write
cert_obj = self._session.upload_cert(filename,
contents)
try:
# Pass to session to check and write
cert_obj = self._session.upload_cert(filename,
contents)
except IOError:
LOGGER.error("An error occurred whilst uploading the certificate")

# Return error if something went wrong
if cert_obj is None:
Expand Down
15 changes: 15 additions & 0 deletions framework/python/src/common/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Track testing status."""
import copy
import datetime
import pytz
import json
import os
from common import util, logger
Expand Down Expand Up @@ -389,6 +390,8 @@ def get_timezone(self):

def upload_cert(self, filename, content):

now = datetime.datetime.now(pytz.utc)

try:
# Parse bytes into x509 object
cert = x509.load_pem_x509_certificate(content, default_backend())
Expand All @@ -399,9 +402,14 @@ def upload_cert(self, filename, content):
issuer = cert.issuer.get_attributes_for_oid(
NameOID.ORGANIZATION_NAME)[0].value

status = 'Valid'
if now > cert.not_valid_after_utc:
status = 'Expired'

# Craft python dictionary with values
cert_obj = {
'name': common_name,
'status': status,
'organisation': issuer,
'expires': cert.not_valid_after_utc,
'filename': filename
Expand Down Expand Up @@ -430,6 +438,8 @@ def load_certs(self):

LOGGER.debug(f'Loading certificates from {CERTS_PATH}')

now = datetime.datetime.now(pytz.utc)

self._certs = []

for cert_file in os.listdir(CERTS_PATH):
Expand All @@ -450,9 +460,14 @@ def load_certs(self):
issuer = cert.issuer.get_attributes_for_oid(
NameOID.ORGANIZATION_NAME)[0].value

status = 'Valid'
if now > cert.not_valid_after_utc:
status = 'Expired'

# Craft python dictionary with values
cert_obj = {
'name': common_name,
'status': status,
'organisation': issuer,
'expires': cert.not_valid_after_utc,
'filename': cert_file
Expand Down
1 change: 1 addition & 0 deletions framework/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ markdown==3.5.2

# Requirements for the session
cryptography==42.0.7
pytz==2024.1
2 changes: 1 addition & 1 deletion make/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: Testrun
Version: 1.2.2
Version: 1.3-alpha
Architecture: amd64
Maintainer: Google <boddey@google.com>
Homepage: https://github.com/google/testrun
Expand Down