Skip to content

Commit

Permalink
CNJR-4593: Merge pull request #19 from Conjur-Enterprise/rename-userf…
Browse files Browse the repository at this point in the history
…acing-dryrun

Rename policy validation interfaces to dry run
  • Loading branch information
codihuston authored and GitHub Enterprise committed Jul 15, 2024
2 parents aa505a8 + 2aeff12 commit 7a19f1b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.12.2] - 2024-07-15

### Changed
- Rename validate policy type definition to Dry Run (CNJR-4593)

## [0.12.1] - 2024-07-08

### Changed
- Automatically add 'api' prefix to Conjur Cloud base URLs (CNJR-5493)
- Default Account to 'conjur' for Conjur Cloud (CNJR-5494)
- Update validate policy type definition from (CNJR-4593)
- Update validate policy type definition (CNJR-4593)

## [0.12.0] - 2024-05-05

Expand Down Expand Up @@ -197,7 +202,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial version

[Unreleased]: https://github.com/cyberark/conjur-api-go/compare/v0.11.4...HEAD
[Unreleased]: https://github.com/cyberark/conjur-api-go/compare/v0.12.2...HEAD
[v0.12.2]: https://github.com/cyberark/conjur-api-go/compare/v0.12.1...v0.12.2
[v0.12.1]: https://github.com/cyberark/conjur-api-go/compare/v0.12.0...v0.12.1
[v0.12.0]: https://github.com/cyberark/conjur-api-go/compare/v0.11.4...v0.12.0
[0.11.4]: https://github.com/cyberark/conjur-api-go/compare/v0.11.2...v0.11.4
[0.11.2]: https://github.com/cyberark/conjur-api-go/compare/v0.11.1...v0.11.2
[0.11.1]: https://github.com/cyberark/conjur-api-go/compare/v0.11.0...v0.11.1
Expand Down
18 changes: 9 additions & 9 deletions conjurapi/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ type PolicyResponse struct {
Version uint32 `json:"version"`
}

// ValidationErrors contains information about any errors that occurred during
// DryRunErrors contains information about any errors that occurred during
// policy validation.
type ValidationErrors struct {
type DryRunErrors struct {
Line int `json:"line"`
Column int `json:"column"`
Message string `json:"message"`
}

// ValidatePolicyResponse contains information about the policy validation and
// DryRunPolicyResponse contains information about the policy validation and
// whether it was successful.
type ValidatePolicyResponse struct {
type DryRunPolicyResponse struct {
// Status of the policy validation.
Status string `json:"status"`
Errors []ValidationErrors `json:"errors"`
Status string `json:"status"`
Errors []DryRunErrors `json:"errors"`
}

// LoadPolicy submits new policy data or polciy changes to the server.
Expand All @@ -67,7 +67,7 @@ func (c *Client) LoadPolicy(mode PolicyMode, policyID string, policy io.Reader)
return &policyResponse, response.JSONResponse(resp, &policyResponse)
}

func (c *Client) ValidatePolicy(mode PolicyMode, policyID string, policy io.Reader) (*ValidatePolicyResponse, error) {
func (c *Client) DryRunPolicy(mode PolicyMode, policyID string, policy io.Reader) (*DryRunPolicyResponse, error) {
req, err := c.LoadPolicyRequest(mode, policyID, policy, true)
if err != nil {
return nil, err
Expand All @@ -78,6 +78,6 @@ func (c *Client) ValidatePolicy(mode PolicyMode, policyID string, policy io.Read
return nil, err
}

policyResponse := ValidatePolicyResponse{}
return &policyResponse, response.PolicyValidationResponse(resp, &policyResponse)
policyResponse := DryRunPolicyResponse{}
return &policyResponse, response.DryRunPolicyJSONResponse(resp, &policyResponse)
}
4 changes: 2 additions & 2 deletions conjurapi/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestClient_LoadPolicy(t *testing.T) {
- !user %s
`, username)

resp, err := conjur.ValidatePolicy(
resp, err := conjur.DryRunPolicy(
PolicyModePut,
"root",
strings.NewReader(policy),
Expand All @@ -149,7 +149,7 @@ func TestClient_LoadPolicy(t *testing.T) {
- user %s
`, username)

resp, err := conjur.ValidatePolicy(
resp, err := conjur.DryRunPolicy(
PolicyModePut,
"root",
strings.NewReader(policy),
Expand Down
4 changes: 2 additions & 2 deletions conjurapi/response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ func EmptyResponse(resp *http.Response) error {
return NewConjurError(resp)
}

// PolicyValidationResponse checks the HTTP status of the response. If it's less than
// DryRunPolicyJSONResponse checks the HTTP status of the response. If it's less than
// 300 or equal to 422, it returns the response body as JSON. Otherwise it
// returns a NewConjurError.
func PolicyValidationResponse(resp *http.Response, obj interface{}) error {
func DryRunPolicyJSONResponse(resp *http.Response, obj interface{}) error {
logResponse(resp)
if resp.StatusCode < 300 || resp.StatusCode == 422 {
body, err := readBody(resp)
Expand Down

0 comments on commit 7a19f1b

Please sign in to comment.