Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/confmap/provider/testutils"
)

func newConfigurableHTTPProvider(scheme SchemeType, set confmap.ProviderSettings) *provider {
Expand All @@ -51,6 +52,7 @@ func answerGet(w http.ResponseWriter, _ *http.Request) {
// Generate a self signed certificate specific for the tests. Based on
// https://go.dev/src/crypto/tls/generate_cert.go
func generateCertificate(t *testing.T, hostname string) (cert, key string, err error) {
testutils.SkipIfFIPSOnly(t, "x509.CreateCertificate uses SHA-1")
priv, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
return "", "", fmt.Errorf("Failed to generate private key: %w", err)
Expand Down
21 changes: 21 additions & 0 deletions confmap/provider/testutils/fips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package testutils // import "go.opentelemetry.io/collector/confmap/provider/testutils"

import (
"os"
"strings"
"testing"
)

// SkipIfFIPSOnly will mark the passed test as skipped if GODEBUG=fips140=only is detected.
// If GODEBUG=fips140=on, go may call non-compliant algorithms and the test does not need to be skipped.
func SkipIfFIPSOnly(t *testing.T, msg string) {
// NOTE: This only checks env var; at the time of writing fips140 can only be set via env
// other GODEBUG settings can be set via embedded comments or in go.mod, we may need to account for this in the future.
s := os.Getenv("GODEBUG")
if strings.Contains(s, "fips140=only") {
t.Skip("GODEBUG=fips140=only detected, skipping test:", msg)
}
}
Loading