daemon: Gitea v1 API adapter (git.westphal.fr is Gitea, not GitLab); fix golang Dockerfile to 1.26; sudo docker in deploy
This commit is contained in:
+11
-12
@@ -1,6 +1,6 @@
|
||||
package main
|
||||
|
||||
// gitlab_test.go — PAT connect + project mapping against httptest upstream.
|
||||
// gitlab_test.go — token connect + repo mapping against httptest upstream (Gitea v1).
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -14,30 +14,29 @@ import (
|
||||
func newGitLabUpstream(t *testing.T) (*httptest.Server, *GitLab) {
|
||||
t.Helper()
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/api/v4/user", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Header.Get("Private-Token") != "pat-good" {
|
||||
mux.HandleFunc("/api/v1/user", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Header.Get("Authorization") != "token pat-good" {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"username":"alice"}`))
|
||||
_, _ = w.Write([]byte(`{"login":"alice"}`))
|
||||
})
|
||||
mux.HandleFunc("/api/v4/projects", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Header.Get("Private-Token") != "pat-good" {
|
||||
mux.HandleFunc("/api/v1/user/repos", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Header.Get("Authorization") != "token pat-good" {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
q := r.URL.Query()
|
||||
if q.Get("membership") != "true" || q.Get("order_by") != "last_activity_at" {
|
||||
if r.URL.Query().Get("limit") == "" {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`[
|
||||
{"path_with_namespace":"team/b","name":"B","namespace":{"path":"team"},
|
||||
"last_activity_at":"2024-02-02T00:00:00Z","web_url":"https://gl/team/b","default_branch":"main"},
|
||||
{"path_with_namespace":"team/a","name":"A","namespace":{"path":"team"},
|
||||
"last_activity_at":"2024-03-03T00:00:00Z","web_url":"https://gl/team/a","default_branch":"trunk"}
|
||||
{"full_name":"team/b","name":"B","owner":{"login":"team"},
|
||||
"updated_at":"2024-02-02T00:00:00Z","html_url":"https://gl/team/b","default_branch":"main"},
|
||||
{"full_name":"team/a","name":"A","owner":{"login":"team"},
|
||||
"updated_at":"2024-03-03T00:00:00Z","html_url":"https://gl/team/a","default_branch":"trunk"}
|
||||
]`))
|
||||
})
|
||||
ts := httptest.NewServer(mux)
|
||||
|
||||
Reference in New Issue
Block a user