Files
kcrypt-challenger/cmd/discovery/client/flow_test.go
Dimitris Karakasilis 89b07027cb Remove unecessary wrapper
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2025-09-23 16:25:23 +03:00

68 lines
2.0 KiB
Go

package client
import (
"testing"
"github.com/jaypipes/ghw/pkg/block"
"github.com/kairos-io/kairos-sdk/types"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestClient(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Discovery Client Suite")
}
var _ = Describe("Flow Detection", func() {
var client *Client
BeforeEach(func() {
// Create a test client with basic config and logger
client = &Client{}
client.Config.Kcrypt.Challenger.Server = "http://test-server.local"
client.Logger = types.NewKairosLogger("test-client", "debug", false)
})
Context("TPM attestation capabilities", func() {
It("should handle TPM operations", func() {
// Test that client can be created without errors
// TPM availability testing requires actual hardware
Expect(client).ToNot(BeNil())
})
})
Context("Logging functionality", func() {
It("should have a valid logger", func() {
// Test that client has a valid logger
Expect(client.Logger).NotTo(BeNil())
// Test debug logging works without error
client.Logger.Debugf("Test log entry for flow detection")
// If we get here without panic, logging is working
Expect(true).To(BeTrue())
})
})
Context("Flow routing", func() {
It("should call the appropriate flow based on TPM availability", func() {
// This test verifies that GetPassphrase correctly routes to either TPM or legacy flow
// Since we don't have a real server, we expect an error, but the routing logic should work
_, err := client.GetPassphrase(&block.Partition{
Name: "test-partition",
UUID: "test-uuid",
FilesystemLabel: "test-label",
}, 1)
// We expect an error since there's no real server, but the flow selection should work
Expect(err).To(HaveOccurred())
// The flow routing logic now uses the logger instead of the file,
// so we just verify the error occurred as expected
Expect(err.Error()).To(ContainSubstring("TPM attestation flow not implemented yet"))
})
})
})