Skip to content

Commit

Permalink
DXE-3736 Review implementation edgegrid part
Browse files Browse the repository at this point in the history
  • Loading branch information
mimazaka authored and wzagrajcz committed Jul 5, 2024
1 parent 6e40f4c commit 0ae91f6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cloudaccess/access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (r AccessKeyRequest) Validate() error {
// Validate validates UpdateAccessKeyRequest
func (r UpdateAccessKeyRequest) Validate() error {
return edgegriderr.ParseValidationErrors(validation.Errors{
"AccessKeyName": validation.Validate(r.AccessKeyName, validation.Required),
"AccessKeyName": validation.Validate(r.AccessKeyName, validation.Required, validation.Length(1, 50)),
})
}

Expand Down
11 changes: 11 additions & 0 deletions pkg/cloudaccess/access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ func TestUpdateAccessKey(t *testing.T) {
assert.Equal(t, "update an access key: struct validation: AccessKeyName: cannot be blank", err.Error())
},
},
"max length - validation error": {
params: AccessKeyRequest{
AccessKeyUID: 1,
},
accessKey: UpdateAccessKeyRequest{
AccessKeyName: "asdfghjkloasdfghjkloasdfghjkloasdfghjkloasdfghjkloasdfghjkloasdfghjkloasdfghjklo",
},
withError: func(t *testing.T, err error) {
assert.Equal(t, "update an access key: struct validation: AccessKeyName: the length must be between 1 and 50", err.Error())
},
},
"500 internal server error": {
accessKey: UpdateAccessKeyRequest{
AccessKeyName: "key2",
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudaccess/access_key_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type (
GetAccessKeyVersionStatusResponse struct {
AccessKeyVersion *KeyVersion `json:"accessKeyVersion"`
ProcessingStatus ProcessingType `json:"processingStatus"`
RequestDate string `json:"requestDate"`
RequestDate time.Time `json:"requestDate"`
RequestedBy string `json:"requestedBy"`
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudaccess/access_key_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGetAccessKeyVersionStatus(t *testing.T) {
expectedPath: "/cam/v1/access-key-version-create-requests/1",
expectedResponse: &GetAccessKeyVersionStatusResponse{
ProcessingStatus: ProcessingInProgress,
RequestDate: "2021-02-26T14:54:38.622074Z",
RequestDate: time.Date(2021, 2, 26, 14, 54, 38, 622074000, time.UTC),
RequestedBy: "user",
AccessKeyVersion: &KeyVersion{
AccessKeyUID: 123,
Expand All @@ -65,7 +65,7 @@ func TestGetAccessKeyVersionStatus(t *testing.T) {
expectedPath: "/cam/v1/access-key-version-create-requests/1",
expectedResponse: &GetAccessKeyVersionStatusResponse{
ProcessingStatus: ProcessingInProgress,
RequestDate: "2021-02-26T14:54:38.622074Z",
RequestDate: time.Date(2021, 2, 26, 14, 54, 38, 622074000, time.UTC),
RequestedBy: "user",
},
},
Expand Down

0 comments on commit 0ae91f6

Please sign in to comment.