Skip to content

Bugs in regular expression matching  #39

Closed
@jacksgt

Description

@jacksgt

Hello!

I upgraded to the latest release (1.2.0) to get the new regular expression matching feature (thanks also for the additional documentation!).

Unfortunately, I encountered two limitations:

  1. property value cannot contain spaces

It is not possible to use an expression like try "at most 5 times every 5s to get Route named '${ROUTE_NAME}' and verify that '.spec.tls.certificate' matches 'BEGIN CERTIFICATE'".

Given this input:

oc --no-headers=true --namespace=test-cert-manager-1234 get route test-selfsigned-certificates -o jsonpath='{.spec.tls.certificate}'
-----BEGIN CERTIFICATE-----
MIIClzCCAjygAwIBAgIRANLLorHDbAcObjpzZunlA/MwCgYIKoZIzj0EAwIwHDEa
MBgGA1UEAxMRc2VsZnNpZ25lZC1pc3N1ZXIwHhcNMjMwNzI4MTQ0NDUzWhcNMjMx
MDI2MTQ0NDUzWjAAMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoNpJ
qiSEgZ72mOt6yyI4EVncF5UWLdyBetvQYAmWsOZLPnPZy2ZgfMKEN9+RfJROuHAs
MqMxHqgicxmNMuiWNbWr4+8Q7gYHsbnLXvsa15ykRM/Yz/lHrQAPiUPvFnLC8xKC
Z+RozJi3lspR8VHc7RYzg/NmiehYypz78sBV9IMKnC/Qz4zaZUG+pXsEr6kddW3x
4cs5VpSsrz9XZvDbd5To1BiB4MPQEKBOO6hvBqryS+1CjbRNA/TizEQkC8ZKaiH6
AtPuhhuoFPnVcpb0pWEalRfq4f4lrVvJfRgcuABjeoHK9oYlikWKFdPcZHbXGrIr
kwK0UKK+AIOWmdTpVwIDAQABo4GvMIGsMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUE
DDAKBggrBgEFBQcDATAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFHLHEmRxTNZP
HjyKOdO5Kt+qoUhFMFYGA1UdEQEB/wRMMEqCSHRlc3Qtc2VsZnNpZ25lZC1jZXJ0
aWZpY2F0ZXMtdGVzdC1jZXJ0LW1hbmFnZXItMTIzNC5jbHUtamFjay1kZXYuY2Vy
bi5jaDAKBggqhkjOPQQDAgNJADBGAiEA7dd13BTx7ZujRw/n1hK1A34J1eJbZPJO
yvl5J3M3FH0CIQCTRWWIgKgSN/Uh7mR07D/A7G1POCSkb3z1Hh4B+yM0lw==
-----END CERTIFICATE-----

This line of code fails:

value=$(echo "$line" | awk '{ print $2 }')

		# Keep the second column (property to verify)
		value=$(echo "$line" | awk '{ print $2 }')

and only keeps -----BEGIN in value (instead of the entire line).


  1. regular expression cannot begin with dashes

It is not possible to use an expression like try "at most 5 times every 5s to get Route named '${ROUTE_NAME}' and verify that '.spec.tls.certificate' matches '----END CERTIFICATE----$'", because the leading dashes get interpreted as an argument for bash.

   Valid expression. Verification in progress...
   grep: unrecognized option '-----END CERTIFICATE-----'
   Usage: grep [OPTION]... PATTERNS [FILE]...
   Try 'grep --help' for more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions