Skip to content

Commit

Permalink
Merge pull request #797 from marcpfuller/path_secretname
Browse files Browse the repository at this point in the history
refactor(mod): Refactor Secret DTO to rename Path property to SecretName
  • Loading branch information
Lenny Goodell authored Feb 14, 2023
2 parents 5ded580 + 36dc869 commit 57cbd60
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion clients/http/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestVersion(t *testing.T) {
func TestAddSecret(t *testing.T) {
expected := dtoCommon.BaseResponse{}
req := dtoCommon.NewSecretRequest(
"testPath",
"testSecretName",
[]dtoCommon.SecretDataKeyValue{
{Key: "username", Value: "tester"},
{Key: "password", Value: "123"},
Expand Down
10 changes: 5 additions & 5 deletions dtos/common/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ type SecretDataKeyValue struct {
Value string `json:"value" validate:"required"`
}

// SecretRequest is the request DTO for storing supplied secret at specified Path in the Secret Store
// SecretRequest is the request DTO for storing supplied secret at a given SecretName in the Secret Store
// See detail specified by the V2 API swagger in openapi/v2
type SecretRequest struct {
BaseRequest `json:",inline"`
Path string `json:"path" validate:"required"`
SecretName string `json:"secretName" validate:"required"`
SecretData []SecretDataKeyValue `json:"secretData" validate:"required,gt=0,dive"`
}

Expand All @@ -48,7 +48,7 @@ func (sr *SecretRequest) Validate() error {
func (sr *SecretRequest) UnmarshalJSON(b []byte) error {
var alias struct {
BaseRequest
Path string
SecretName string
SecretData []SecretDataKeyValue
}

Expand All @@ -65,10 +65,10 @@ func (sr *SecretRequest) UnmarshalJSON(b []byte) error {
return nil
}

func NewSecretRequest(path string, secretData []SecretDataKeyValue) SecretRequest {
func NewSecretRequest(secretName string, secretData []SecretDataKeyValue) SecretRequest {
return SecretRequest{
BaseRequest: NewBaseRequest(),
Path: path,
SecretName: secretName,
SecretData: secretData,
}
}
4 changes: 2 additions & 2 deletions dtos/common/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var validRequest = SecretRequest{
RequestId: TestUUID,
Versionable: NewVersionable(),
},
Path: "something",
SecretName: "something",
SecretData: []SecretDataKeyValue{
{Key: "username", Value: "User1"},
{Key: "password", Value: "password"},
Expand All @@ -52,7 +52,7 @@ var missingValueSecretData = []SecretDataKeyValue{

func TestSecretsRequest_Validate(t *testing.T) {
validNoPath := validRequest
validNoPath.Path = ""
validNoPath.SecretName = ""
validWithPath := validRequest
validNoRequestId := validRequest
validNoRequestId.RequestId = ""
Expand Down

0 comments on commit 57cbd60

Please sign in to comment.