@@ -37,6 +37,7 @@ import (
3737 "github.com/snapcore/snapd/osutil/keyboard"
3838 "github.com/snapcore/snapd/osutil/user"
3939 "github.com/snapcore/snapd/overlord/fdestate"
40+ fdeBackend "github.com/snapcore/snapd/overlord/fdestate/backend"
4041 "github.com/snapcore/snapd/overlord/snapstate"
4142 "github.com/snapcore/snapd/overlord/state"
4243 "github.com/snapcore/snapd/overlord/storecontext"
@@ -775,3 +776,78 @@ type ReprovisionSetupDataType = reprovisionSetupData
775776func GetCachedReprovisionRecoveryKey (data * ReprovisionSetupDataType ) * keys.RecoveryKey {
776777 return data .recoveryKey
777778}
779+
780+ func MakeReprovisionSetupData (rkey * keys.RecoveryKey , checkContext * secboot.PreinstallCheckContext ) * ReprovisionSetupDataType {
781+ return & reprovisionSetupData {
782+ recoveryKey : rkey ,
783+ checkContext : checkContext ,
784+ }
785+ }
786+
787+ func MockFdestateGetEncryptedContainers (f func (st * state.State ) ([]fdeBackend.EncryptedContainer , error )) (restore func ()) {
788+ old := fdestateGetEncryptedContainers
789+ fdestateGetEncryptedContainers = f
790+ return func () {
791+ fdestateGetEncryptedContainers = old
792+ }
793+ }
794+
795+ func DoReprovision (m * DeviceManager , t * state.Task ) error {
796+ return m .doReprovision (t , nil )
797+ }
798+
799+ func MockSecbootListContainerUnlockKeyNames (f func (disk string ) ([]string , error )) (restore func ()) {
800+ return testutil .Mock (& secbootListContainerUnlockKeyNames , f )
801+ }
802+
803+ func MockSecbootTestProtectorKey (f func (ctx context.Context , disk string , keyName string , key []byte ) (bool , error )) (restore func ()) {
804+ return testutil .Mock (& secbootTestProtectorKey , f )
805+ }
806+
807+ func MockSecbootRenameContainerKey (f func (disk string , from , to string ) error ) (restore func ()) {
808+ return testutil .Mock (& secbootRenameContainerKey , f )
809+ }
810+
811+ func MockSecbootGetPCRHandleFromToken (f func (disk string , name string ) (uint32 , error )) (restore func ()) {
812+ return testutil .Mock (& secbootGetPCRHandleFromToken , f )
813+ }
814+
815+ func MockSecbootReleasePCRResourceHandle (f func (nv uint32 ) error ) (restore func ()) {
816+ return testutil .Mock (& secbootReleasePCRResourceHandle , f )
817+ }
818+
819+ func MockSecbootDeleteContainerKey (f func (disk string , name string ) error ) (restore func ()) {
820+ return testutil .Mock (& secbootDeleteContainerKey , f )
821+ }
822+
823+ func MockBootMakeRunnableReprovision (f func (model * asserts.Model , protector secboot.KeyProtectorFactory , encryption * boot.EncryptionSetup ) error ) (restore func ()) {
824+ return testutil .Mock (& bootMakeRunnableReprovision , f )
825+ }
826+
827+ func MockSecbootListContainerRecoveryKeyNames (f func (disk string ) ([]string , error )) (restore func ()) {
828+ return testutil .Mock (& secbootListContainerRecoveryKeyNames , f )
829+ }
830+
831+ func MockSecbootSaveCheckResult (f func (pcc * secboot.PreinstallCheckContext , filename string ) error ) (restore func ()) {
832+ return testutil .Mock (& secbootSaveCheckResult , f )
833+ }
834+
835+ func MockSecbootCheckResult (f func (pcc * secboot.PreinstallCheckContext ) (* secboot.PreinstallCheckResult , error )) (restore func ()) {
836+ return testutil .Mock (& secbootCheckResult , f )
837+ }
838+
839+ func MockSnapstateKernelInfo (f func (st * state.State , deviceCtx snapstate.DeviceContext ) (* snap.Info , error )) (restore func ()) {
840+ return testutil .Mock (& snapstateKernelInfo , f )
841+ }
842+
843+ func MockKeysNewProtectorKey (f func () (keys.ProtectorKey , error )) (restore func ()) {
844+ return testutil .Mock (& keysNewProtectorKey , f )
845+ }
846+
847+ func MockKeysCreateProtectedKey (f func (k keys.ProtectorKey , primaryKey []byte ) (* keys.PlainKey , []byte , []byte , error )) (restore func ()) {
848+ return testutil .Mock (& keysCreateProtectedKey , f )
849+ }
850+
851+ func MockKeysPlainKeyWrite (f func (key * keys.PlainKey , writer keys.KeyDataWriter ) error ) (restore func ()) {
852+ return testutil .Mock (& keysPlainKeyWrite , f )
853+ }
0 commit comments