Skip to content

Commit

Permalink
Fixes 4712: add content override for sslverifystatus (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsherrill authored Sep 13, 2024
1 parent 83e804e commit b3c7714
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions pkg/candlepin_client/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

const OverrideNameBaseUrl = "baseurl"
const OverrideNameCaCert = "sslcacert"
const OverrideSSLVerifyStatus = "sslverifystatus"
const OverrideModuleHotfixes = "module_hotfixes"

func GetContentID(repoConfigUUID string) string {
Expand Down
6 changes: 6 additions & 0 deletions pkg/tasks/candlepin_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func ContentOverridesForRepo(orgId string, domainName string, templateUUID strin
ContentLabel: &repo.Label,
Value: utils.Ptr(" "), // use a single space because candlepin doesn't allow "" or null
})
// Disable OCSP checking, as aws doesn't support it?
mapping = append(mapping, caliri.ContentOverrideDTO{
Name: utils.Ptr(candlepin_client.OverrideSSLVerifyStatus),
ContentLabel: &repo.Label,
Value: utils.Ptr("0"),
})

if repo.OrgID == orgId { // Don't override RH repo baseurls
distPath := customTemplateSnapshotPath(templateUUID, repo.UUID)
Expand Down
16 changes: 13 additions & 3 deletions pkg/tasks/candlepin_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,17 @@ func (s *CandlepinHelpersTest) TestContentOverridesForRepo() {
overrides, err := ContentOverridesForRepo(orgId, domain, templateUUID, pulpContentPath, Repo)
assert.NoError(s.T(), err)

assert.Len(s.T(), overrides, 2)
assert.Len(s.T(), overrides, 3)
assert.Contains(s.T(), overrides, caliri.ContentOverrideDTO{
Name: utils.Ptr("sslcacert"),
ContentLabel: &Repo.Label,
Value: utils.Ptr(" "),
})
assert.Contains(s.T(), overrides, caliri.ContentOverrideDTO{
Name: utils.Ptr("sslverifystatus"),
ContentLabel: &Repo.Label,
Value: utils.Ptr("0"),
})
assert.Contains(s.T(), overrides, caliri.ContentOverrideDTO{
Name: utils.Ptr("baseurl"),
ContentLabel: utils.Ptr(Repo.Label),
Expand All @@ -102,7 +107,7 @@ func (s *CandlepinHelpersTest) TestContentOverridesForRepo() {
Repo.ModuleHotfixes = true
overrides, err = ContentOverridesForRepo(orgId, domain, templateUUID, pulpContentPath, Repo)
assert.NoError(s.T(), err)
assert.Len(s.T(), overrides, 3)
assert.Len(s.T(), overrides, 4)
assert.Contains(s.T(), overrides, caliri.ContentOverrideDTO{
Name: utils.Ptr("module_hotfixes"),
ContentLabel: &Repo.Label,
Expand All @@ -112,10 +117,15 @@ func (s *CandlepinHelpersTest) TestContentOverridesForRepo() {
Repo.Origin = config.OriginRedHat
overrides, err = ContentOverridesForRepo(orgId, domain, templateUUID, pulpContentPath, Repo)
assert.NoError(s.T(), err)
assert.Len(s.T(), overrides, 1)
assert.Len(s.T(), overrides, 2)
assert.Contains(s.T(), overrides, caliri.ContentOverrideDTO{
Name: utils.Ptr("sslcacert"),
ContentLabel: &Repo.Label,
Value: utils.Ptr(" "),
})
assert.Contains(s.T(), overrides, caliri.ContentOverrideDTO{
Name: utils.Ptr("sslverifystatus"),
ContentLabel: &Repo.Label,
Value: utils.Ptr("0"),
})
}
16 changes: 13 additions & 3 deletions test/integration/update_template_content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ func (s *UpdateTemplateContentSuite) TestCreateCandlepinContent() {
ContentLabel: utils.Ptr(repo1.Label),
Value: utils.Ptr(" "),
}
repo1VerifyOverride := caliri.ContentOverrideDTO{
Name: utils.Ptr("sslverifystatus"),
ContentLabel: utils.Ptr(repo1.Label),
Value: utils.Ptr("0"),
}

repo2UrlOverride := caliri.ContentOverrideDTO{
Name: utils.Ptr("baseurl"),
Expand All @@ -163,6 +168,11 @@ func (s *UpdateTemplateContentSuite) TestCreateCandlepinContent() {
ContentLabel: utils.Ptr(repo2.Label),
Value: utils.Ptr(" "),
}
repo2VerifyOverride := caliri.ContentOverrideDTO{
Name: utils.Ptr("sslverifystatus"),
ContentLabel: utils.Ptr(repo2.Label),
Value: utils.Ptr("0"),
}

// Update template with new repository
payload := s.updateTemplateContentAndWait(orgID, tempResp.UUID, []string{repo1.UUID})
Expand Down Expand Up @@ -200,7 +210,7 @@ func (s *UpdateTemplateContentSuite) TestCreateCandlepinContent() {
}
assert.Contains(s.T(), environmentContentIDs, repo1ContentID)

s.AssertOverrides(ctx, environmentID, []caliri.ContentOverrideDTO{repo1UrlOverride, repo1CaOverride})
s.AssertOverrides(ctx, environmentID, []caliri.ContentOverrideDTO{repo1UrlOverride, repo1CaOverride, repo1VerifyOverride})

// Add new repositories to template
updateReq := api.TemplateUpdateRequest{
Expand Down Expand Up @@ -237,7 +247,7 @@ func (s *UpdateTemplateContentSuite) TestCreateCandlepinContent() {
assert.Contains(s.T(), environmentContentIDs, repo2ContentID)
assert.NotContains(s.T(), environmentContentIDs, repo3ContentID)

s.AssertOverrides(ctx, environmentID, []caliri.ContentOverrideDTO{repo1UrlOverride, repo1CaOverride, repo2UrlOverride, repo2CaOverride})
s.AssertOverrides(ctx, environmentID, []caliri.ContentOverrideDTO{repo1UrlOverride, repo1CaOverride, repo1VerifyOverride, repo2UrlOverride, repo2CaOverride, repo2VerifyOverride})

// Remove 2 repositories from the template
updateReq = api.TemplateUpdateRequest{
Expand Down Expand Up @@ -273,7 +283,7 @@ func (s *UpdateTemplateContentSuite) TestCreateCandlepinContent() {
assert.NotContains(s.T(), environmentContentIDs, repo2ContentID)
assert.NotContains(s.T(), environmentContentIDs, repo3ContentID)

s.AssertOverrides(ctx, environmentID, []caliri.ContentOverrideDTO{repo1UrlOverride, repo1CaOverride})
s.AssertOverrides(ctx, environmentID, []caliri.ContentOverrideDTO{repo1UrlOverride, repo1CaOverride, repo1VerifyOverride})

// Rename template
updateReq = api.TemplateUpdateRequest{
Expand Down

0 comments on commit b3c7714

Please sign in to comment.