Source file src/crypto/fips140/fips140_test.go

     1  // Copyright 2025 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package fips140
     6  
     7  import (
     8  	"internal/godebug"
     9  	"internal/testenv"
    10  	"testing"
    11  )
    12  
    13  func TestImmutableGODEBUG(t *testing.T) {
    14  	fips140Enabled := Enabled()
    15  	fips140Setting := godebug.New("fips140")
    16  	fips140SettingValue := fips140Setting.Value()
    17  
    18  	tests := []string{
    19  		"fips140=off",
    20  		"fips140=on",
    21  		"fips140=",
    22  		"",
    23  	}
    24  	for _, godebugValue := range tests {
    25  		t.Run(godebugValue, func(t *testing.T) {
    26  			testenv.SetGODEBUG(t, godebugValue)
    27  			if Enabled() != fips140Enabled {
    28  				t.Errorf("Enabled() changed after setting GODEBUG=%s", godebugValue)
    29  			}
    30  			if fips140Setting.Value() != fips140SettingValue {
    31  				t.Errorf("fips140Setting.Value() changed after setting GODEBUG=%s", godebugValue)
    32  			}
    33  		})
    34  	}
    35  }
    36  

View as plain text