| 1 | package server |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "net/http" |
| 6 | "net/http/cookiejar" |
| 7 | "net/http/httptest" |
| 8 | "net/url" |
| 9 | "os" |
| 10 | "os/exec" |
| 11 | "path/filepath" |
| 12 | "strings" |
| 13 | "testing" |
| 14 | |
| 15 | "gitlab.com/Timfa/bluegit/internal/auth" |
| 16 | "gitlab.com/Timfa/bluegit/internal/config" |
| 17 | "gitlab.com/Timfa/bluegit/internal/gitrepo" |
| 18 | "gitlab.com/Timfa/bluegit/internal/store" |
| 19 | ) |
| 20 | |
| 21 | func TestPipelineEditorAndProtectedBranch(t *testing.T) { |
| 22 | if _, err := exec.LookPath("git"); err != nil { |
| 23 | t.Skip("git ontbreekt") |
| 24 | } |
| 25 | storage := t.TempDir() |
| 26 | st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32()) |
| 27 | if err != nil { |
| 28 | t.Fatal(err) |
| 29 | } |
| 30 | t.Cleanup(func() { _ = st.Close() }) |
| 31 | cfg := config.Config{ |
| 32 | BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage, |
| 33 | Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"}, |
| 34 | Git: config.Git{Binary: "git", DefaultBranch: "master"}, |
| 35 | } |
| 36 | srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"} |
| 37 | ts := httptest.NewServer(srv.Handler()) |
| 38 | t.Cleanup(ts.Close) |
| 39 | jar, _ := cookiejar.New(nil) |
| 40 | tim := &http.Client{Jar: jar} |
| 41 | res, err := tim.Get(ts.URL + "/login") |
| 42 | if err != nil { |
| 43 | t.Fatal(err) |
| 44 | } |
| 45 | page := read(t, res) |
| 46 | res, err = tim.PostForm(ts.URL+"/new/repo", url.Values{ |
| 47 | "csrf": {csrfOf(t, page)}, "name": {"cied"}, "visibility": {"public"}, |
| 48 | }) |
| 49 | if err != nil { |
| 50 | t.Fatal(err) |
| 51 | } |
| 52 | page = read(t, res) |
| 53 | res, err = tim.PostForm(ts.URL+"/settings/tokens", url.Values{"csrf": {csrfOf(t, page)}, "name": {"laptop"}}) |
| 54 | if err != nil { |
| 55 | t.Fatal(err) |
| 56 | } |
| 57 | token := between(read(t, res), `<p class="code">`, "</p>") |
| 58 | remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/cied.git" |
| 59 | work := t.TempDir() |
| 60 | git(t, work, "init", "-b", "master") |
| 61 | git(t, work, "config", "user.email", "tim@users.git.timfalken.com") |
| 62 | git(t, work, "config", "user.name", "tim") |
| 63 | yml := "stages:\n - test\nunit:\n stage: test\n image: alpine:3.20\n script:\n - echo ok\n" |
| 64 | writeFile(t, filepath.Join(work, "blue-ci-cd.yml"), yml) |
| 65 | git(t, work, "add", "blue-ci-cd.yml") |
| 66 | git(t, work, "commit", "-m", "ci") |
| 67 | git(t, work, "remote", "add", "origin", remote) |
| 68 | git(t, work, "push", "-u", "origin", "master") |
| 69 | git(t, work, "checkout", "-b", "feature") |
| 70 | git(t, work, "push", "-u", "origin", "feature") |
| 71 | |
| 72 | res, err = tim.Get(ts.URL + "/tim/cied/-/ci/editor?ref=feature") |
| 73 | if err != nil { |
| 74 | t.Fatal(err) |
| 75 | } |
| 76 | editor := read(t, res) |
| 77 | for _, want := range []string{"Pipeline Editor", "No issues found", "echo ok", "ci-gutter", "Commit message"} { |
| 78 | if !strings.Contains(editor, want) { |
| 79 | t.Errorf("editor mist %q", want) |
| 80 | } |
| 81 | } |
| 82 | csrf := csrfOf(t, editor) |
| 83 | res, err = tim.PostForm(ts.URL+"/tim/cied/-/ci/lint", url.Values{ |
| 84 | "csrf": {csrf}, "ref": {"feature"}, "body": {"stages: [\n"}, |
| 85 | }) |
| 86 | if err != nil { |
| 87 | t.Fatal(err) |
| 88 | } |
| 89 | raw := read(t, res) |
| 90 | var lint struct { |
| 91 | Status string `json:"status"` |
| 92 | StatusClass string `json:"statusClass"` |
| 93 | Issues []struct { |
| 94 | Line int `json:"line"` |
| 95 | Text string `json:"text"` |
| 96 | } `json:"issues"` |
| 97 | } |
| 98 | if err := json.Unmarshal([]byte(raw), &lint); err != nil { |
| 99 | t.Fatalf("lint json: %v\n%s", err, raw) |
| 100 | } |
| 101 | if lint.StatusClass != "failed" || len(lint.Issues) == 0 || strings.Count(lint.Issues[0].Text, "invalid YAML") != 1 { |
| 102 | t.Fatalf("lint: %+v", lint) |
| 103 | } |
| 104 | |
| 105 | changed := "stages:\n - test\nunit:\n stage: test\n image: alpine:3.20\n script:\n - echo changed\n" |
| 106 | res, err = tim.PostForm(ts.URL+"/tim/cied/-/ci/editor", url.Values{ |
| 107 | "csrf": {csrf}, "base": {"feature"}, "branch": {"feature"}, "message": {"pas de editor aan"}, "body": {changed}, |
| 108 | }) |
| 109 | if err != nil { |
| 110 | t.Fatal(err) |
| 111 | } |
| 112 | saved := read(t, res) |
| 113 | if !strings.Contains(saved, "Committed.") || !strings.Contains(saved, "echo changed") { |
| 114 | t.Fatalf("na commit:\n%s", saved) |
| 115 | } |
| 116 | dir := gitrepo.Dir(storage, "tim", "cied") |
| 117 | if got := mustGit(t, dir, "show", "feature:blue-ci-cd.yml"); !strings.Contains(got, "echo changed") { |
| 118 | t.Fatalf("bestand: %s", got) |
| 119 | } |
| 120 | if msg := mustGit(t, dir, "log", "-1", "--format=%s", "feature"); strings.TrimSpace(msg) != "pas de editor aan" { |
| 121 | t.Fatalf("bericht: %s", msg) |
| 122 | } |
| 123 | |
| 124 | res, err = tim.PostForm(ts.URL+"/tim/cied/-/ci/editor", url.Values{ |
| 125 | "csrf": {csrfOf(t, saved)}, "base": {"feature"}, "branch": {"ci-try"}, "message": {"nieuwe branch"}, "body": {changed}, |
| 126 | }) |
| 127 | if err != nil { |
| 128 | t.Fatal(err) |
| 129 | } |
| 130 | _ = read(t, res) |
| 131 | if got := mustGit(t, dir, "show", "ci-try:blue-ci-cd.yml"); !strings.Contains(got, "echo changed") { |
| 132 | t.Fatalf("nieuwe branch: %s", got) |
| 133 | } |
| 134 | |
| 135 | ctx := res.Request.Context() |
| 136 | repo, err := st.RepoByPath(ctx, "tim", "cied") |
| 137 | if err != nil { |
| 138 | t.Fatal(err) |
| 139 | } |
| 140 | ada, err := st.UpsertUser(ctx, 3, "ada", "", false) |
| 141 | if err != nil { |
| 142 | t.Fatal(err) |
| 143 | } |
| 144 | if err := st.SetMember(ctx, "repo", repo.ID, "ada", "developer"); err != nil { |
| 145 | t.Fatal(err) |
| 146 | } |
| 147 | adaC := clientAs(t, ts.URL, st, ada.ID) |
| 148 | res, err = adaC.Get(ts.URL + "/tim/cied/-/ci/editor?ref=master") |
| 149 | if err != nil { |
| 150 | t.Fatal(err) |
| 151 | } |
| 152 | adaPage := read(t, res) |
| 153 | res, err = adaC.PostForm(ts.URL+"/tim/cied/-/ci/editor", url.Values{ |
| 154 | "csrf": {csrfOf(t, adaPage)}, "base": {"master"}, "branch": {"master"}, "message": {"ada op master"}, "body": {changed + "\n"}, |
| 155 | }) |
| 156 | if err != nil { |
| 157 | t.Fatal(err) |
| 158 | } |
| 159 | denied := read(t, res) |
| 160 | if !strings.Contains(denied, "This branch is protected.") { |
| 161 | t.Fatalf("beschermd:\n%s", denied) |
| 162 | } |
| 163 | if got := mustGit(t, dir, "show", "master:blue-ci-cd.yml"); strings.Contains(got, "echo changed") { |
| 164 | t.Fatalf("master veranderde:\n%s", got) |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | func TestPipelineEditorMissingFile(t *testing.T) { |
| 169 | if _, err := exec.LookPath("git"); err != nil { |
| 170 | t.Skip("git ontbreekt") |
| 171 | } |
| 172 | storage := t.TempDir() |
| 173 | st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32()) |
| 174 | if err != nil { |
| 175 | t.Fatal(err) |
| 176 | } |
| 177 | t.Cleanup(func() { _ = st.Close() }) |
| 178 | cfg := config.Config{ |
| 179 | BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage, |
| 180 | Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"}, |
| 181 | Git: config.Git{Binary: "git", DefaultBranch: "master"}, |
| 182 | } |
| 183 | srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true"} |
| 184 | ts := httptest.NewServer(srv.Handler()) |
| 185 | t.Cleanup(ts.Close) |
| 186 | jar, _ := cookiejar.New(nil) |
| 187 | tim := &http.Client{Jar: jar} |
| 188 | res, err := tim.Get(ts.URL + "/login") |
| 189 | if err != nil { |
| 190 | t.Fatal(err) |
| 191 | } |
| 192 | page := read(t, res) |
| 193 | res, err = tim.PostForm(ts.URL+"/new/repo", url.Values{ |
| 194 | "csrf": {csrfOf(t, page)}, "name": {"leeg"}, "visibility": {"public"}, |
| 195 | }) |
| 196 | if err != nil { |
| 197 | t.Fatal(err) |
| 198 | } |
| 199 | page = read(t, res) |
| 200 | res, err = tim.PostForm(ts.URL+"/settings/tokens", url.Values{"csrf": {csrfOf(t, page)}, "name": {"laptop"}}) |
| 201 | if err != nil { |
| 202 | t.Fatal(err) |
| 203 | } |
| 204 | token := between(read(t, res), `<p class="code">`, "</p>") |
| 205 | remote := strings.Replace(ts.URL, "http://", "http://tim:"+token+"@", 1) + "/tim/leeg.git" |
| 206 | work := t.TempDir() |
| 207 | git(t, work, "init", "-b", "master") |
| 208 | git(t, work, "config", "user.email", "tim@users.git.timfalken.com") |
| 209 | git(t, work, "config", "user.name", "tim") |
| 210 | writeFile(t, filepath.Join(work, "README.md"), "leeg\n") |
| 211 | git(t, work, "add", "README.md") |
| 212 | git(t, work, "commit", "-m", "leesmij") |
| 213 | git(t, work, "remote", "add", "origin", remote) |
| 214 | git(t, work, "push", "-u", "origin", "master") |
| 215 | |
| 216 | res, err = tim.Get(ts.URL + "/tim/leeg/-/ci/editor") |
| 217 | if err != nil { |
| 218 | t.Fatal(err) |
| 219 | } |
| 220 | editor := read(t, res) |
| 221 | for _, want := range []string{"echo hello", "No issues found", "There is no blue-ci-cd.yml on this branch yet.", `value="Add blue-ci-cd.yml"`, `name="branch" value="master"`} { |
| 222 | if !strings.Contains(editor, want) { |
| 223 | t.Errorf("editor mist %q", want) |
| 224 | } |
| 225 | } |
| 226 | if strings.Contains(editor, "must be a mapping") || strings.Contains(editor, `name="open_mr"`) { |
| 227 | t.Fatalf("beheerder ziet een fout of een merge-request:\n%s", editor) |
| 228 | } |
| 229 | |
| 230 | ctx := res.Request.Context() |
| 231 | repo, err := st.RepoByPath(ctx, "tim", "leeg") |
| 232 | if err != nil { |
| 233 | t.Fatal(err) |
| 234 | } |
| 235 | ada, err := st.UpsertUser(ctx, 3, "ada", "", false) |
| 236 | if err != nil { |
| 237 | t.Fatal(err) |
| 238 | } |
| 239 | if err := st.SetMember(ctx, "repo", repo.ID, "ada", "developer"); err != nil { |
| 240 | t.Fatal(err) |
| 241 | } |
| 242 | adaC := clientAs(t, ts.URL, st, ada.ID) |
| 243 | res, err = adaC.Get(ts.URL + "/tim/leeg/-/ci/editor?ref=master") |
| 244 | if err != nil { |
| 245 | t.Fatal(err) |
| 246 | } |
| 247 | adaPage := read(t, res) |
| 248 | for _, want := range []string{`name="open_mr" value="1" checked`, `name="branch" value="add-blue-ci-cd"`, "You cannot commit to this protected branch."} { |
| 249 | if !strings.Contains(adaPage, want) { |
| 250 | t.Errorf("ada mist %q\n%s", want, adaPage) |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | dir := gitrepo.Dir(storage, "tim", "leeg") |
| 255 | res, err = adaC.PostForm(ts.URL+"/tim/leeg/-/ci/editor", url.Values{ |
| 256 | "csrf": {csrfOf(t, adaPage)}, "base": {"master"}, "branch": {"master"}, "message": {"ada op master"}, "body": {ciTemplate}, |
| 257 | }) |
| 258 | if err != nil { |
| 259 | t.Fatal(err) |
| 260 | } |
| 261 | denied := read(t, res) |
| 262 | if !strings.Contains(denied, "This branch is protected.") { |
| 263 | t.Fatalf("beschermd:\n%s", denied) |
| 264 | } |
| 265 | if _, err := gitOut(dir, "cat-file", "-e", "master:blue-ci-cd.yml"); err == nil { |
| 266 | t.Fatal("master kreeg toch een ci-bestand") |
| 267 | } |
| 268 | |
| 269 | res, err = adaC.PostForm(ts.URL+"/tim/leeg/-/ci/editor", url.Values{ |
| 270 | "csrf": {csrfOf(t, adaPage)}, "base": {"master"}, "branch": {"master"}, "open_mr": {"1"}, "message": {"ada op master"}, "body": {ciTemplate}, |
| 271 | }) |
| 272 | if err != nil { |
| 273 | t.Fatal(err) |
| 274 | } |
| 275 | bad := read(t, res) |
| 276 | if !strings.Contains(bad, "That branch name cannot be used.") { |
| 277 | t.Fatalf("zelfde branch:\n%s", bad) |
| 278 | } |
| 279 | |
| 280 | job := "stages:\n - test\nunit:\n stage: test\n image: alpine:3.20\n script:\n - echo from-ada\n" |
| 281 | res, err = adaC.PostForm(ts.URL+"/tim/leeg/-/ci/editor", url.Values{ |
| 282 | "csrf": {csrfOf(t, adaPage)}, "base": {"master"}, "branch": {"add-blue-ci-cd"}, "open_mr": {"1"}, "message": {"ada voegt ci toe"}, "body": {job}, |
| 283 | }) |
| 284 | if err != nil { |
| 285 | t.Fatal(err) |
| 286 | } |
| 287 | opened := read(t, res) |
| 288 | if !strings.Contains(opened, "Merge request opened") || !strings.Contains(opened, "ada voegt ci toe") { |
| 289 | t.Fatalf("merge request:\n%s", opened) |
| 290 | } |
| 291 | if got := mustGit(t, dir, "show", "add-blue-ci-cd:blue-ci-cd.yml"); !strings.Contains(got, "echo from-ada") { |
| 292 | t.Fatalf("nieuwe branch: %s", got) |
| 293 | } |
| 294 | if _, err := gitOut(dir, "cat-file", "-e", "master:blue-ci-cd.yml"); err == nil { |
| 295 | t.Fatal("master kreeg het bestand via de merge request") |
| 296 | } |
| 297 | |
| 298 | res, err = tim.Get(ts.URL + "/tim/leeg/-/ci/editor?ref=master") |
| 299 | if err != nil { |
| 300 | t.Fatal(err) |
| 301 | } |
| 302 | again := read(t, res) |
| 303 | res, err = tim.PostForm(ts.URL+"/tim/leeg/-/ci/editor", url.Values{ |
| 304 | "csrf": {csrfOf(t, again)}, "base": {"master"}, "branch": {"master"}, "message": {"Add blue-ci-cd.yml"}, "body": {ciTemplate}, |
| 305 | }) |
| 306 | if err != nil { |
| 307 | t.Fatal(err) |
| 308 | } |
| 309 | saved := read(t, res) |
| 310 | if !strings.Contains(saved, "Committed.") { |
| 311 | t.Fatalf("opslaan:\n%s", saved) |
| 312 | } |
| 313 | if got := mustGit(t, dir, "show", "master:blue-ci-cd.yml"); !strings.Contains(got, "echo hello") { |
| 314 | t.Fatalf("master: %s", got) |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | func TestPipelineEditorEmptyRepo(t *testing.T) { |
| 319 | if _, err := exec.LookPath("git"); err != nil { |
| 320 | t.Skip("git ontbreekt") |
| 321 | } |
| 322 | storage := t.TempDir() |
| 323 | state := t.TempDir() |
| 324 | home := t.TempDir() |
| 325 | if err := os.WriteFile(filepath.Join(home, "secret"), []byte("x\n"), 0o644); err != nil { |
| 326 | t.Fatal(err) |
| 327 | } |
| 328 | if err := os.Chmod(home, 0o555); err != nil { |
| 329 | t.Fatal(err) |
| 330 | } |
| 331 | t.Cleanup(func() { _ = os.Chmod(home, 0o755) }) |
| 332 | t.Setenv("HOME", home) |
| 333 | t.Setenv("TMPDIR", home) |
| 334 | t.Setenv("GIT_AUTHOR_NAME", "hostile") |
| 335 | t.Setenv("GIT_AUTHOR_EMAIL", "hostile@example.com") |
| 336 | t.Setenv("GIT_COMMITTER_NAME", "hostile") |
| 337 | t.Setenv("GIT_COMMITTER_EMAIL", "hostile@example.com") |
| 338 | |
| 339 | st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32()) |
| 340 | if err != nil { |
| 341 | t.Fatal(err) |
| 342 | } |
| 343 | t.Cleanup(func() { _ = st.Close() }) |
| 344 | cfg := config.Config{ |
| 345 | BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage, |
| 346 | Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"}, |
| 347 | Git: config.Git{Binary: "git", DefaultBranch: "master"}, |
| 348 | } |
| 349 | srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git", HookBin: "/bin/true", StateDir: state} |
| 350 | ts := httptest.NewServer(srv.Handler()) |
| 351 | t.Cleanup(ts.Close) |
| 352 | jar, _ := cookiejar.New(nil) |
| 353 | tim := &http.Client{Jar: jar} |
| 354 | res, err := tim.Get(ts.URL + "/login") |
| 355 | if err != nil { |
| 356 | t.Fatal(err) |
| 357 | } |
| 358 | page := read(t, res) |
| 359 | res, err = tim.PostForm(ts.URL+"/new/repo", url.Values{ |
| 360 | "csrf": {csrfOf(t, page)}, "name": {"leeg"}, "visibility": {"public"}, |
| 361 | }) |
| 362 | if err != nil { |
| 363 | t.Fatal(err) |
| 364 | } |
| 365 | _ = read(t, res) |
| 366 | |
| 367 | res, err = tim.Get(ts.URL + "/tim/leeg/-/ci/editor") |
| 368 | if err != nil { |
| 369 | t.Fatal(err) |
| 370 | } |
| 371 | editor := read(t, res) |
| 372 | for _, want := range []string{"There is no blue-ci-cd.yml on this branch yet.", "No issues found", `name="branch" value="master"`} { |
| 373 | if !strings.Contains(editor, want) { |
| 374 | t.Errorf("editor mist %q", want) |
| 375 | } |
| 376 | } |
| 377 | if strings.Contains(editor, `name="open_mr"`) { |
| 378 | t.Fatal("eigenaar ziet een merge-request op master") |
| 379 | } |
| 380 | job := "image: alpine:latest\nbuild:\n stage: build\n script:\n - echo from-owner\n" |
| 381 | res, err = tim.PostForm(ts.URL+"/tim/leeg/-/ci/editor", url.Values{ |
| 382 | "csrf": {csrfOf(t, editor)}, "base": {"master"}, "branch": {"master"}, "message": {"Add blue-ci-cd.yml"}, "body": {job}, |
| 383 | }) |
| 384 | if err != nil { |
| 385 | t.Fatal(err) |
| 386 | } |
| 387 | saved := read(t, res) |
| 388 | if !strings.Contains(saved, "Committed.") || strings.Contains(saved, "could not be committed") { |
| 389 | t.Fatalf("lege repo:\n%s", saved) |
| 390 | } |
| 391 | dir := gitrepo.Dir(storage, "tim", "leeg") |
| 392 | if got := mustGit(t, dir, "show", "master:blue-ci-cd.yml"); !strings.Contains(got, "echo from-owner") { |
| 393 | t.Fatalf("bestand: %s", got) |
| 394 | } |
| 395 | if who := strings.TrimSpace(mustGit(t, dir, "log", "-1", "--format=%an %ae", "master")); who != "tim tim@users.git.timfalken.com" { |
| 396 | t.Fatalf("identiteit %q", who) |
| 397 | } |
| 398 | if _, err := exec.Command("git", "--git-dir", dir, "rev-parse", "--verify", "master^").CombinedOutput(); err == nil { |
| 399 | t.Fatal("eerste commit heeft een parent") |
| 400 | } |
| 401 | scratch := filepath.Join(state, "tmp") |
| 402 | if _, err := os.Stat(scratch); err != nil { |
| 403 | t.Fatalf("werkmap niet onder de state: %v", err) |
| 404 | } |
| 405 | |
| 406 | ctx := res.Request.Context() |
| 407 | repo, err := st.RepoByPath(ctx, "tim", "leeg") |
| 408 | if err != nil { |
| 409 | t.Fatal(err) |
| 410 | } |
| 411 | ada, err := st.UpsertUser(ctx, 3, "ada", "", false) |
| 412 | if err != nil { |
| 413 | t.Fatal(err) |
| 414 | } |
| 415 | if err := st.SetMember(ctx, "repo", repo.ID, "ada", "developer"); err != nil { |
| 416 | t.Fatal(err) |
| 417 | } |
| 418 | adaC := clientAs(t, ts.URL, st, ada.ID) |
| 419 | res, err = adaC.Get(ts.URL + "/tim/leeg/-/ci/editor?ref=master") |
| 420 | if err != nil { |
| 421 | t.Fatal(err) |
| 422 | } |
| 423 | adaPage := read(t, res) |
| 424 | res, err = adaC.PostForm(ts.URL+"/tim/leeg/-/ci/editor", url.Values{ |
| 425 | "csrf": {csrfOf(t, adaPage)}, "base": {"master"}, "branch": {"master"}, "message": {"ada op master"}, "body": {job + "\n"}, |
| 426 | }) |
| 427 | if err != nil { |
| 428 | t.Fatal(err) |
| 429 | } |
| 430 | denied := read(t, res) |
| 431 | if !strings.Contains(denied, "This branch is protected.") { |
| 432 | t.Fatalf("beschermd:\n%s", denied) |
| 433 | } |
| 434 | if strings.Contains(mustGit(t, dir, "show", "master:blue-ci-cd.yml"), "ada op master") { |
| 435 | t.Fatal("developer veranderde master") |
| 436 | } |
| 437 | } |