Skip to content

Commit

Permalink
Merge pull request #314 from galasa-dev/ash-cps-property
Browse files Browse the repository at this point in the history
CPS property name now accepts @ symbol
  • Loading branch information
techcobweb authored Dec 4, 2024
2 parents fcc6442 + 5d7c323 commit 6646319
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/errors/errorMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ var (
"The namespace must start with a character in the 'a-z' range, followed by characters in the 'a'-'z' or '0'-'9' ranges only.", 1140, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_FAILED_TO_COMPILE_PROPERTY_FIELD_REGEX = NewMessageType("GAL1141E: Unable to compile the regex pattern for Galasa Property field '%s'. Reason: '%s'", 1141, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_INVALID_PROPERTY_FIELD_FORMAT = NewMessageType("GAL1142E: The %s field value, '%s', provided does not match formatting requirements. "+
"The %s field value must start with a character in the 'a-z' or 'A-Z' range, followed by any characters in the 'a'-'z', 'A'-'Z', '0'-'9', '.' (period), '-' (dash) or '_' (underscore) ranges only.", 1142, STACK_TRACE_NOT_WANTED)
"The %s field value must start with a character in the 'a-z' or 'A-Z' range, followed by any characters in the 'a'-'z', 'A'-'Z', '0'-'9', '.' (period), '-' (dash) or '_' (underscore) or '@' (at) ranges only.", 1142, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_QUERY_RUNS_NON_OK_STATUS = NewMessageType("GAL1143E: Could not query run results. Server returned a non-200 code (%s)", 1143, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_GET_TEST_CATALOG_CONTENTS_FAILED = NewMessageType("GAL1144E: Could not use url '%s' to retrieve the contents of the test catalog from stream '%s'. Http error from the Galasa server is '%v'", 1144, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_FAILED_TO_CREATE_BEARER_TOKEN_FOLDER = NewMessageType("GAL1145E: Failed to create folder for bearer tokens at '%s'\n", 1145, STACK_TRACE_NOT_WANTED)
Expand Down
2 changes: 1 addition & 1 deletion pkg/properties/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

const (
PROPERTY_NAMESPACE_PATTERN = "^[a-z][a-z0-9]+$"
PROPERTY_NAME_PATTERN = "^[a-zA-Z][a-zA-Z0-9\\.\\-\\_]+$"
PROPERTY_NAME_PATTERN = "^[a-zA-Z][a-zA-Z0-9\\.\\-\\_@]+$"
)

func validateInputsAreNotEmpty(namespace string, name string) error {
Expand Down
16 changes: 16 additions & 0 deletions pkg/properties/propertiesDelete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ func TestDeletePropertyValueReturnsOk(t *testing.T) {
assert.Nil(t, err)
}

func TestDeletePropertyValueWithAtSymbolReturnsOk(t *testing.T) {
//Given...
namespace := "validnamespace"
name := "[email protected]"

server := newDeletePropertiesServletMock(t)
apiClient := api.InitialiseAPI(server.URL)
defer server.Close()

//When
err := DeleteProperty(namespace, name, apiClient)

//Then
assert.Nil(t, err)
}

// invalid OR empty namespace, valid propertyname
func TestDeletePropertyWithInvalidNamesapceFormatReturnsError(t *testing.T) {
//Given...
Expand Down
38 changes: 38 additions & 0 deletions pkg/properties/propertiesSet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,25 @@ func TestCreatePropertyWithValidNamespaceReturnsOk(t *testing.T) {
assert.Nil(t, err)
}

func TestCreatePropertyWithValidNamespaceWithAtSymbolReturnsOk(t *testing.T) {
//Given...
namespace := "validnamespace"
name := "[email protected]"
value := "someValue"

server := newSetPropertiesServletMock(t)
apiServerUrl := server.URL
defer server.Close()

apiClient := api.InitialiseAPI(apiServerUrl)

//When
err := SetProperty(namespace, name, value, apiClient)

//Then
assert.Nil(t, err)
}

func TestUpdatePropertyWithInvalidNamespaceAndInvalidPropertyNameReturnsError(t *testing.T) {
//Given...
namespace := "invalidnamespace"
Expand Down Expand Up @@ -146,6 +165,25 @@ func TestUpdatePropertyWithValidNamespaceAndVaidNameValueReturnsOk(t *testing.T)
assert.Nil(t, err)
}

func TestUpdatePropertyWithValidNamespaceAndVaidNameValueWithAtSymbolReturnsOk(t *testing.T) {
//Given...
namespace := "validnamespace"
name := "[email protected]"
value := "updatedValue"

server := newSetPropertiesServletMock(t)
apiServerUrl := server.URL
defer server.Close()

apiClient := api.InitialiseAPI(apiServerUrl)

//When
err := SetProperty(namespace, name, value, apiClient)

//Then
assert.Nil(t, err)
}

func TestUpdatePropertyWithInvalidNamespaceAndValidNameReturnsError(t *testing.T) {
//Given...
namespace := "invalidnamespace"
Expand Down

0 comments on commit 6646319

Please sign in to comment.