Skip to content

Commit

Permalink
testing regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
ounsworth committed Nov 2, 2024
1 parent 2b0f1f4 commit 1f849fe
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/test_certs_r4_with_oqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ printf "Build time: %s\n\n" "$(date)" > $logfile

alreadyTestedOIDs=";"

_FILENAME_REGEX = re.compile(r'^(?P<friendlyName>.*)-(?P<oid>[^\.0-9]+)_ta.der$', re.IGNORECASE)

# Requires an input: the TA file to test
test_ta () {
tafile=$1
resultsfile=$2

tafileBasename=$(basename $tafile)

# strip off the friendly name
tafileBasename=$(echo $tafileBasename | egrep -o '[^-]+_ta.der$')


# strip off the file suffix to get the OID name
if [[ $(expr match "$tafileBasename" ".*_ta\.pem$") != 0 ]]; then
oid=${tafileBasename%_ta.pem}
elif [[ $(expr match "$tafileBasename" ".*_ta\.der$") != 0 ]]; then
if [[ $(expr match "$tafileBasename" ".*_ta\.der$") != 0 ]]; then
oid=${tafileBasename%_ta.der}
elif [[ $(expr match "$tafileBasename" ".*_ta\.der\.pem$") != 0 ]]; then
oid=${tafileBasename%_ta.der.pem}

printf "DEBUG: filename: $tafileBasename, OID: $oid\n"

else # It's some other filename
printf "ERROR: file name is not in the expected format: %s\n" $tafileBasename
printf "ERROR: file name is not in the expected format: %s\n" $tafileBasename >> $logfile
Expand Down

0 comments on commit 1f849fe

Please sign in to comment.