require base_url when an update sets repo_type remote
This commit is contained in:
@@ -151,6 +151,10 @@ func (h *RemotesHandler) update(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, fmt.Sprintf("invalid repo type: %q", remote.RepoType), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if remote.RepoType == models.RepoTypeRemote && remote.BaseURL == "" {
|
||||
http.Error(w, "base_url is required for remote repositories", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if err := remote.ValidateMirrorlist(); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -203,6 +203,8 @@ func TestRepoTypeKeptOnUpdate(t *testing.T) {
|
||||
{"PUT", "/rt-local", `{"package_type":"rpm","description":"x"}`, 200, "rt-local", "local"},
|
||||
{"PUT", "/rt-local", `{"package_type":"rpm","repo_type":""}`, 200, "rt-local", "local"},
|
||||
{"PUT", "/rt-local", `{"package_type":"rpm","repo_type":"bogus"}`, 400, "rt-local", "local"},
|
||||
{"PUT", "/rt-local", `{"package_type":"rpm","repo_type":"remote"}`, 400, "rt-local", "local"},
|
||||
{"PUT", "/rt-remote", `{"package_type":"rpm","repo_type":"local"}`, 200, "rt-remote", "local"},
|
||||
} {
|
||||
if c := do(t, h, s.method, s.path, s.json); c != s.code {
|
||||
t.Fatalf("step %d %s %s = %d, want %d", i, s.method, s.path, c, s.code)
|
||||
|
||||
Reference in New Issue
Block a user