Skip to content

Commit

Permalink
add headers and test
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Fernandez <mariofer@redhat.com>
  • Loading branch information
marioferh committed Jun 23, 2023
1 parent 468e483 commit 75926da
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions assets/alertmanager/alertmanager.yaml
Expand Up @@ -144,6 +144,10 @@ spec:
app.kubernetes.io/version: 0.25.0
priorityClassName: system-cluster-critical
replicas: 2
web:
httpConfig:
headers:
contentSecurityPolicy: "frame-ancestors 'none'"
resources:
requests:
cpu: 4m
Expand Down
4 changes: 4 additions & 0 deletions assets/prometheus-k8s/prometheus.yaml
Expand Up @@ -180,6 +180,10 @@ spec:
openshift.io/cluster-monitoring: "true"
probeSelector: {}
replicas: 2
web:
httpConfig:
headers:
contentSecurityPolicy: "frame-ancestors 'none'"
resources:
requests:
cpu: 70m
Expand Down
24 changes: 24 additions & 0 deletions pkg/manifests/manifests_test.go
Expand Up @@ -1419,6 +1419,30 @@ func TestRemoteWriteAuthorizationConfig(t *testing.T) {
}
}

func TestPrometheusK8sHttpConfig(t *testing.T) {
config :=
`prometheusK8s:`

c, err := NewConfigFromString(config, false)
if err != nil {
t.Fatal(err)
}

f := NewFactory("openshift-monitoring", "openshift-user-workload-monitoring", c, defaultInfrastructureReader(), &fakeProxyReader{}, NewAssets(assetsPath), &APIServerConfig{}, &configv1.Console{})
p, err := f.PrometheusK8s(
&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}},
&v1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "foo"}},
nil,
)
if err != nil {
t.Fatal(err)
}

if p.Spec.Web.HTTPConfig.Headers.ContentSecurityPolicy != "frame-ancestors 'none'" {
t.Fatal("httpconfig headers wrong")
}
}

func TestPrometheusK8sConfiguration(t *testing.T) {
c, err := NewConfigFromString(`prometheusK8s:
retention: 25h
Expand Down

0 comments on commit 75926da

Please sign in to comment.