aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/service_test.go
diff options
context:
space:
mode:
authorMax Resnick <max@ofmax.li>2024-04-15 22:23:59 -0700
committerMax Resnick <max@ofmax.li>2024-04-20 22:07:25 -0700
commit948a7398906cb8aba21b5538f7b6906a6aa1df96 (patch)
tree956498d304897f3856d028a87e48b8454b2dbc00 /internal/admin/service_test.go
parent506cef4bb4cc2cfa1eb1bdf9390706f6b35bff70 (diff)
downloadgo-git-server-948a7398906cb8aba21b5538f7b6906a6aa1df96.tar.gz
feat: readonly fs support, policy built in temp
Diffstat (limited to '')
-rw-r--r--internal/admin/service_test.go30
1 files changed, 19 insertions, 11 deletions
diff --git a/internal/admin/service_test.go b/internal/admin/service_test.go
index bbdab85..13a0007 100644
--- a/internal/admin/service_test.go
+++ b/internal/admin/service_test.go
@@ -5,7 +5,6 @@ import (
"log"
"os"
"path/filepath"
- "strings"
"testing"
)
@@ -97,12 +96,16 @@ func TestInitServer(t *testing.T) {
// stuff
svc.Reload()
// check policy file to make sure it was saved
- data, err := os.ReadFile(destPolicyFile)
- if err != nil {
- t.Fatal(err)
+ expectedPolicies := [][]string{
+ {"role:maintainers", "/thisismynewrepo/info/refs", "GET"},
+ {"role:maintainers", "/thisismynewrepo/git-upload-pack", "POST"},
+ {"role:maintainers", "/thisismynewrepo/git-receive-pack", "POST"},
}
- if !strings.Contains(string(data), "thisismynewrepo") {
- t.Fatal("expected to find test new repo but didn't")
+ for _, policy := range expectedPolicies {
+ if !svc.HasPolicy(policy[0], policy[1], policy[2]) {
+ t.Log("policy not found", policy)
+ t.Fail()
+ }
}
})
t.Run("test reload config err", func(t *testing.T) {
@@ -121,12 +124,16 @@ func TestInitServer(t *testing.T) {
// stuff
svc.Reload()
// check policy file to make sure it wasn't saved
- data, err := os.ReadFile(destPolicyFile)
- if err != nil {
- log.Fatal(err)
+ expectedPolicies := [][]string{
+ {"role:admin", "/mgmt/info/refs", "GET"},
+ {"role:admin", "/mgmt/git-upload-pack", "POST"},
+ {"role:admin", "/mgmt/git-receive-pack", "POST"},
}
- if !strings.Contains(string(data), "mgmt") {
- log.Fatal("expected to mgmt repo but didn't in policy")
+ for _, policy := range expectedPolicies {
+ if !svc.HasPolicy(policy[0], policy[1], policy[2]) {
+ t.Log("policy not found", policy)
+ t.Fail()
+ }
}
})
t.Run("test an unitialized server config", func(t *testing.T) {
@@ -139,6 +146,7 @@ func TestInitServer(t *testing.T) {
true)
if svc.Conf.Name != "default config" {
log.Fatalf("found %s expected 'default config'", svc.Conf.Name)
+ t.Fail()
}
})
}