diff options
author | Sandro <sandro.jaeckel@gmail.com> | 2022-12-27 21:23:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-27 21:23:33 +0100 |
commit | 6c0b60981c256136e1aa2a719f462d8dadcfa4e9 (patch) | |
tree | 8da09fe185564d06a5c478c47cfa081854cff978 /pkgs/servers/web-apps | |
parent | 2bcb322973e6b28ebb13f12a1ca03563775c82e3 (diff) | |
parent | 80d9e24cbf15faba75acd955770add1344315e41 (diff) |
Merge pull request #202978 from urandom2/linx-server
Fixes https://github.com/NixOS/nixpkgs/issues/188667
Diffstat (limited to 'pkgs/servers/web-apps')
-rw-r--r-- | pkgs/servers/web-apps/linx-server/default.nix | 33 | ||||
-rw-r--r-- | pkgs/servers/web-apps/linx-server/test.patch | 74 |
2 files changed, 107 insertions, 0 deletions
diff --git a/pkgs/servers/web-apps/linx-server/default.nix b/pkgs/servers/web-apps/linx-server/default.nix new file mode 100644 index 0000000000000..995eacf792e4d --- /dev/null +++ b/pkgs/servers/web-apps/linx-server/default.nix @@ -0,0 +1,33 @@ +{ buildGoModule +, fetchFromGitHub +, go-rice +, lib +}: + +buildGoModule rec { + pname = "linx-server"; + version = "unstable-2021-12-24"; + + src = fetchFromGitHub { + owner = "zizzydizzymc"; + repo = pname; + rev = "3f503442f10fca68a3212975b23cf74d92c9988c"; + hash = "sha256-tTHw/rIb2Gs5i5vZKsSgbUePIY7Np6HofBXu4TTjKbw="; + }; + + # upstream tests are broken, see zizzydizzymc/linx-server#34 + patches = [ ./test.patch ]; + + vendorHash = "sha256-/N3AXrPyENp3li4X86LNXsfBYbjJulk+0EAyogPNIpc="; + + nativeBuildInputs = [ go-rice ]; + + preBuild = "rice embed-go"; + + meta = with lib; { + description = "Self-hosted file/code/media sharing website."; + homepage = "https://put.icu"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ urandom ]; + }; +} diff --git a/pkgs/servers/web-apps/linx-server/test.patch b/pkgs/servers/web-apps/linx-server/test.patch new file mode 100644 index 0000000000000..7303aecaf8ef7 --- /dev/null +++ b/pkgs/servers/web-apps/linx-server/test.patch @@ -0,0 +1,74 @@ +diff --git a/server_test.go b/server_test.go +index fc225ce..2df3608 100644 +--- a/server_test.go ++++ b/server_test.go +@@ -446,63 +446,6 @@ func TestPostJSONUpload(t *testing.T) { + } + } + +-func TestPostJSONUploadMaxExpiry(t *testing.T) { +- mux := setup() +- Config.maxExpiry = 300 +- +- // include 0 to test edge case +- // https://github.com/andreimarcu/linx-server/issues/111 +- testExpiries := []string{"86400", "-150", "0"} +- for _, expiry := range testExpiries { +- w := httptest.NewRecorder() +- +- filename := generateBarename() + ".txt" +- +- var b bytes.Buffer +- mw := multipart.NewWriter(&b) +- fw, err := mw.CreateFormFile("file", filename) +- if err != nil { +- t.Fatal(err) +- } +- +- fw.Write([]byte("File content")) +- mw.Close() +- +- req, err := http.NewRequest("POST", "/upload/", &b) +- req.Header.Set("Content-Type", mw.FormDataContentType()) +- req.Header.Set("Accept", "application/json") +- req.Header.Set("Linx-Expiry", expiry) +- if err != nil { +- t.Fatal(err) +- } +- +- mux.ServeHTTP(w, req) +- +- if w.Code != 200 { +- t.Log(w.Body.String()) +- t.Fatalf("Status code is not 200, but %d", w.Code) +- } +- +- var myjson RespOkJSON +- err = json.Unmarshal([]byte(w.Body.String()), &myjson) +- if err != nil { +- t.Fatal(err) +- } +- +- myExp, err := strconv.ParseInt(myjson.Expiry, 10, 64) +- if err != nil { +- t.Fatal(err) +- } +- +- expected := time.Now().Add(time.Duration(Config.maxExpiry) * time.Second).Unix() +- if myExp != expected { +- t.Fatalf("File expiry is not %d but %s", expected, myjson.Expiry) +- } +- } +- +- Config.maxExpiry = 0 +-} +- + func TestPostExpiresJSONUpload(t *testing.T) { + mux := setup() + w := httptest.NewRecorder() +@@ -1301,5 +1244,4 @@ func TestPutAndGetCLI(t *testing.T) { + if !strings.HasPrefix(contentType, "text/plain") { + t.Fatalf("Didn't receive file directly but %s", contentType) + } +- + } |