32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestDirectoryImportRequiresExplicitGovernanceConfirmationAndPrivateInput(t *testing.T) {
|
|
var output bytes.Buffer
|
|
if run(nil, func(string) string { return "" }, &output) == nil || output.Len() != 0 {
|
|
t.Fatal("unconfigured importer must not connect or report success")
|
|
}
|
|
path := filepath.Join(t.TempDir(), "directory.json")
|
|
if os.WriteFile(path, []byte(`{"complete":false}`), 0644) != nil {
|
|
t.Fatal("fixture creation failed")
|
|
}
|
|
env := func(k string) string {
|
|
return map[string]string{"QAOPS_CONFIRM_DIRECTORY_IMPORT": "import-governance-directory", "DOBOTAI_OPS_TENANT_KEY": "fixture", "DATABASE_URL": "postgres://invalid.invalid/no_connection_expected"}[k]
|
|
}
|
|
if run([]string{path}, env, &output) == nil {
|
|
t.Fatal("public personnel input accepted")
|
|
}
|
|
if os.Chmod(path, 0600) != nil {
|
|
t.Fatal("fixture chmod failed")
|
|
}
|
|
if run([]string{path}, env, &output) == nil || output.Len() != 0 {
|
|
t.Fatal("partial sync accepted or importer reported fabricated success")
|
|
}
|
|
}
|