internal: wrap calls to os standard library functions
All checks were successful
test / test (push) Successful in 19s

This change helps tests stub out and simulate OS behaviour during the sealing process. This also removes dependency on XDG_RUNTIME_DIR as the internal.System implementation provided to App provides a compat directory inside the tmpdir-based share when XDG_RUNTIME_DIR is unavailable.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
2024-10-23 21:46:21 +09:00
parent e35c5fe3ed
commit 6bc5be7e5a
16 changed files with 161 additions and 101 deletions

View File

@@ -3,6 +3,8 @@ package app
import (
"os/exec"
"sync"
"git.ophivana.moe/security/fortify/internal"
)
type App interface {
@@ -22,6 +24,8 @@ type App interface {
type app struct {
// application unique identifier
id *ID
// operating system interface
os internal.System
// underlying user switcher process
cmd *exec.Cmd
// shim setup abort reason and completion
@@ -61,8 +65,9 @@ func (a *app) WaitErr() error {
return a.waitErr
}
func New() (App, error) {
func New(os internal.System) (App, error) {
a := new(app)
a.id = new(ID)
a.os = os
return a, newAppID(a.id)
}