mirror of
https://github.com/kairos-io/tpm-helpers.git
synced 2025-09-16 14:50:25 +00:00
Fixup tests, add testing pipelines and small refactors
Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
This commit is contained in:
47
tpm_test.go
47
tpm_test.go
@@ -9,30 +9,6 @@ import (
|
||||
. "github.com/rancher-sandbox/go-tpm/backend"
|
||||
)
|
||||
|
||||
// In order to run this suite a swtpm socket is required. e.g.:
|
||||
// swtpm socket --server type=unixio,path=/tmp/tpm-server --ctrl type=unixio,path=/tmp/tpm-ctrl --tpm2
|
||||
// SWTPM_SOCKET=/tmp/tpm-ctrl ginkgo -r ./
|
||||
|
||||
var _ = Describe("TPM with SWTPM", func() {
|
||||
socket := os.Getenv("SWTPM_SOCKET")
|
||||
Context("opening socket connection", func() {
|
||||
// Note, this doesn't work
|
||||
PIt("dials in just fine", func() {
|
||||
if socket == "" {
|
||||
Skip("No socket file specified")
|
||||
}
|
||||
|
||||
b, err := Socket(socket)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
str, err := GetPubHash(WithCommandChannel(b))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
Expect(str).ToNot(BeEmpty())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var _ = Describe("Simulated TPM", func() {
|
||||
Context("opening socket connection", func() {
|
||||
It("dials in just fine", func() {
|
||||
@@ -48,7 +24,30 @@ var _ = Describe("Simulated TPM", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
str2, err := GetPubHash(Emulated, WithSeed(1))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
str3, err := GetPubHash(Emulated, WithSeed(2))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str).To(Equal(str2))
|
||||
Expect(str).ToNot(Equal(str3))
|
||||
})
|
||||
})
|
||||
|
||||
Context("from a socket", func() {
|
||||
// In order to run this test a swtpm socket is required. e.g.:
|
||||
// swtpm socket --server type=unixio,path=/tmp/tpm-server --ctrl type=unixio,path=/tmp/tpm-ctrl --tpm2
|
||||
// TPM_SOCKET=/tmp/tpm-ctrl ginkgo -r ./
|
||||
|
||||
socket := os.Getenv("TPM_SOCKET")
|
||||
It("gets pubhash", func() {
|
||||
if socket == "" {
|
||||
Skip("No socket file specified")
|
||||
}
|
||||
|
||||
b, err := Socket(socket)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
str, err := GetPubHash(WithCommandChannel(b))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str).ToNot(BeEmpty())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user