Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #599 Policy #601

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions internal/handler/v2/config/policy/config_create_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,21 @@ func ConfigCreatePolicy(w http.ResponseWriter, r *http.Request) {
return
}

// updates organisation policy url
err = updateOrganisationPolicyUrl(savedPolicy.Url, organisationId)
count, err := prepo.GetPolicyCountByOrganisation()
if err != nil {
m := fmt.Sprintf("Failed to update organisation policy url: %v", organisationId)
m := "Failed to count policies"
common.HandleErrorV2(w, http.StatusInternalServerError, m, err)
return
}
if count == 1 {
// updates organisation policy url
err = updateOrganisationPolicyUrl(savedPolicy.Url, organisationId)
if err != nil {
m := fmt.Sprintf("Failed to update organisation policy url: %v", organisationId)
common.HandleErrorV2(w, http.StatusInternalServerError, m, err)
return
}
}

// Constructing the response
var resp addPolicyResp
Expand Down
15 changes: 12 additions & 3 deletions internal/handler/v2/config/policy/config_update_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,22 @@ func ConfigUpdatePolicy(w http.ResponseWriter, r *http.Request) {
return
}

// updates organisation policy url
err = updateOrganisationPolicyUrl(savedPolicy.Url, organisationId)
policyRepo.Init(organisationId)
first_policy, err := policyRepo.GetFirstPolicy()
if err != nil {
m := fmt.Sprintf("Failed to update organisation policy url: %v", organisationId)
m := "Failed to fetch first policy"
common.HandleErrorV2(w, http.StatusInternalServerError, m, err)
return
}
if first_policy.Id == toBeUpdatedPolicy.Id {
// updates organisation policy url
err = updateOrganisationPolicyUrl(savedPolicy.Url, organisationId)
if err != nil {
m := fmt.Sprintf("Failed to update organisation policy url: %v", organisationId)
common.HandleErrorV2(w, http.StatusInternalServerError, m, err)
return
}
}

// Constructing the response
var resp updatePolicyResp
Expand Down
2 changes: 1 addition & 1 deletion internal/tenant/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func SingleTenantConfiguration(config *config.Configuration) {
createOrganisation(config, orgType, organisationAdminId)

// delete all policies
deleteAllPolicies()
// deleteAllPolicies()

// Load image assets for organisation
err := fixture.LoadImageAssetsForSingleTenantConfiguration()
Expand Down