github.com/anonymouse64/snapd@v0.0.0-20210824153203-04c4c42d842d/gadget/install/export_secboot_test.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  // +build !nosecboot
     3  
     4  /*
     5   * Copyright (C) 2020 Canonical Ltd
     6   *
     7   * This program is free software: you can redistribute it and/or modify
     8   * it under the terms of the GNU General Public License version 3 as
     9   * published by the Free Software Foundation.
    10   *
    11   * This program is distributed in the hope that it will be useful,
    12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14   * GNU General Public License for more details.
    15   *
    16   * You should have received a copy of the GNU General Public License
    17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18   *
    19   */
    20  
    21  package install
    22  
    23  import (
    24  	"github.com/snapcore/snapd/secboot"
    25  )
    26  
    27  var (
    28  	EnsureLayoutCompatibility = ensureLayoutCompatibility
    29  	DeviceFromRole            = deviceFromRole
    30  	NewEncryptedDevice        = newEncryptedDevice
    31  )
    32  
    33  func MockSecbootFormatEncryptedDevice(f func(key secboot.EncryptionKey, label, node string) error) (restore func()) {
    34  	old := secbootFormatEncryptedDevice
    35  	secbootFormatEncryptedDevice = f
    36  	return func() {
    37  		secbootFormatEncryptedDevice = old
    38  	}
    39  }
    40  
    41  func MockSecbootAddRecoveryKey(f func(key secboot.EncryptionKey, rkey secboot.RecoveryKey, node string) error) (restore func()) {
    42  	old := secbootAddRecoveryKey
    43  	secbootAddRecoveryKey = f
    44  	return func() {
    45  		secbootAddRecoveryKey = old
    46  	}
    47  }