Skip to content
Open
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
1 change: 1 addition & 0 deletions config/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ func (f *Forwarder) Hash() string {
_, _ = io.WriteString(h, f.TokenClientID)
_, _ = io.WriteString(h, f.TokenSecret)
_, _ = io.WriteString(h, f.Destination)
_, _ = io.WriteString(h, fmt.Sprintf("%v", f.IsFedramp))
return fmt.Sprintf("%x", h.Sum(nil))
}
26 changes: 26 additions & 0 deletions config/model_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package config

import (
"testing"

"github.com/stretchr/testify/assert"
)

// TestForwarderHashIncludesIsFedramp ensures that toggling IsFedramp produces a
// different hash. The hash is what overwatch.AppManager uses to decide whether a
// forwarder from an updated config file is the same service as the running one,
// so a collision means the FedRAMP change is silently never applied.
func TestForwarderHashIncludesIsFedramp(t *testing.T) {
commercial := Forwarder{
URL: "ssh.example.com",
Listener: "127.0.0.1:2222",
TokenClientID: "id",
TokenSecret: "secret",
Destination: "destination",
IsFedramp: false,
}
fedramp := commercial
fedramp.IsFedramp = true

assert.NotEqual(t, commercial.Hash(), fedramp.Hash(), "changing IsFedramp must change the forwarder hash")
}