@@ -37,6 +37,11 @@ func Test_tpmRunner(t *testing.T) {
3737 tpmRunner , err := New (context .TODO (), multislogger .NewNopLogger (), inmemory .NewStore (), withTpmSignerCreator (tpmSignerCreatorMock ))
3838 require .NoError (t , err )
3939
40+ // force the runner to think the machine has a TPM
41+ // not using usual detection methods since were
42+ // mocking it
43+ tpmRunner .machineHasTpm .Store (true )
44+
4045 tpmSignerCreatorMock .On ("CreateKey" ).Return (nil , nil , errors .New ("not available yet" )).Once ()
4146 require .Nil (t , tpmRunner .Public ())
4247
@@ -66,6 +71,11 @@ func Test_tpmRunner(t *testing.T) {
6671 tpmRunner , err := New (context .TODO (), multislogger .NewNopLogger (), store , withTpmSignerCreator (tpmSignerCreatorMock ))
6772 require .NoError (t , err )
6873
74+ // force the runner to think the machine has a TPM
75+ // not using usual detection methods since were
76+ // mocking it
77+ tpmRunner .machineHasTpm .Store (true )
78+
6979 tpmSignerCreatorMock .On ("New" , fakePrivData , fakePubData ).Return (privKey , nil ).Once ()
7080
7181 // the call to public should load the key from the store and signer creator should not be called any more after
@@ -88,6 +98,11 @@ func Test_tpmRunner(t *testing.T) {
8898 tpmRunner , err := New (context .TODO (), multislogger .NewNopLogger (), inmemory .NewStore (), withTpmSignerCreator (tpmSignerCreatorMock ))
8999 require .NoError (t , err )
90100
101+ // force the runner to think the machine has a TPM
102+ // not using usual detection methods since were
103+ // mocking it
104+ tpmRunner .machineHasTpm .Store (true )
105+
91106 tpmSignerCreatorMock .On ("CreateKey" ).Return (nil , nil , errors .New ("not available yet" )).Once ()
92107 require .Nil (t , tpmRunner .Public ())
93108
0 commit comments