Skip to content

Commit

Permalink
secboot: tweak TestResealKey so that it's clearer why it fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 authored and xnox committed Sep 7, 2021
1 parent 173f4da commit ce472d8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions secboot/secboot_sb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,10 @@ func (s *secbootSuite) TestResealKey(c *C) {
resealCalls int
expectedErr string
}{
// happy case
{tpmEnabled: true, resealCalls: 1, expectedErr: ""},

// unhappy cases
{tpmErr: mockErr, expectedErr: "cannot connect to TPM: some error"},
{tpmEnabled: false, expectedErr: "TPM device is not enabled"},
{tpmEnabled: true, missingFile: true, expectedErr: "cannot build EFI image load sequences: file .*/file.efi does not exist"},
Expand All @@ -934,7 +938,6 @@ func (s *secbootSuite) TestResealKey(c *C) {
{tpmEnabled: true, addSystemdEFIStubErr: mockErr, expectedErr: "cannot add systemd EFI stub profile: some error"},
{tpmEnabled: true, addSnapModelErr: mockErr, expectedErr: "cannot add snap model profile: some error"},
{tpmEnabled: true, resealErr: mockErr, resealCalls: 1, expectedErr: "some error"},
{tpmEnabled: true, resealCalls: 1, expectedErr: ""},
} {
mockTPMPolicyAuthKey := []byte{1, 3, 3, 7}
mockTPMPolicyAuthKeyFile := filepath.Join(c.MkDir(), "policy-auth-key-file")
Expand Down Expand Up @@ -1042,7 +1045,7 @@ func (s *secbootSuite) TestResealKey(c *C) {
c.Assert(addSystemdEfiStubCalls, Equals, 1)
c.Assert(addSnapModelCalls, Equals, 1)
} else {
c.Assert(err, ErrorMatches, tc.expectedErr)
c.Assert(err, ErrorMatches, tc.expectedErr, Commentf("%v", tc))
}
c.Assert(resealCalls, Equals, tc.resealCalls)
}
Expand Down

0 comments on commit ce472d8

Please sign in to comment.