feat: add SSO workspace, named shares and Debian release tooling
This commit is contained in:
1 parent
833d908884
commit
87bc33e675
106 files changed
+4160
-5637
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInitWizard(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
configPath := filepath.Join(dir, "settings.json")
|
||||
input := strings.Join([]string{"https://sso.example.test", "client-id", "client-secret", "https://files.example.test", filepath.Join(dir, "files"), filepath.Join(dir, "files.db"), "127.0.0.1", "8080", ""}, "\n")
|
||||
var output bytes.Buffer
|
||||
initCmd.SetIn(strings.NewReader(input))
|
||||
initCmd.SetOut(&output)
|
||||
defer func() { initCmd.SetIn(nil); initCmd.SetOut(nil) }()
|
||||
if err := initCmd.Flags().Set("output", configPath); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := initCmd.RunE(initCmd, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var c initialConfig
|
||||
b, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = json.Unmarshal(b, &c); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.SSO.ClientSecret != "client-secret" || !c.DisableExec || c.Root != filepath.Join(dir, "files") {
|
||||
t.Fatal("configuration lost")
|
||||
}
|
||||
if strings.Contains(output.String(), "client-secret") {
|
||||
t.Fatal("secret leaked to output")
|
||||
}
|
||||
if _, err = os.Stat(c.Database); err != nil {
|
||||
t.Fatal("database not initialized", err)
|
||||
}
|
||||
if !strings.Contains(output.String(), "https://files.example.test/auth/callback") {
|
||||
t.Fatal("callback missing")
|
||||
}
|
||||
initCmd.SetIn(strings.NewReader(input))
|
||||
if err = initCmd.RunE(initCmd, nil); err == nil {
|
||||
t.Fatal("existing configuration overwritten")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user