{"id":31213779,"url":"https://github.com/celrenheit/htest","last_synced_at":"2025-09-21T08:46:57.194Z","repository":{"id":57481110,"uuid":"56514280","full_name":"celrenheit/htest","owner":"celrenheit","description":"A lightweight high-level abstraction for testing HTTP inspired by supertest built around httptest.ResponseRecorder","archived":false,"fork":false,"pushed_at":"2017-06-21T16:08:07.000Z","size":40,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T17:43:04.096Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/celrenheit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-18T14:22:51.000Z","updated_at":"2023-02-07T11:43:54.000Z","dependencies_parsed_at":"2022-09-26T17:41:27.179Z","dependency_job_id":null,"html_url":"https://github.com/celrenheit/htest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/celrenheit/htest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fhtest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fhtest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fhtest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fhtest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/celrenheit","download_url":"https://codeload.github.com/celrenheit/htest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fhtest/sbom","scorecard":{"id":270631,"data":{"date":"2025-08-11","repo":{"name":"github.com/celrenheit/htest","commit":"e34d50431e7f00bb2bb01d01d63f9192955905ef"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/8 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T13:15:24.223Z","repository_id":57481110,"created_at":"2025-08-17T13:15:24.223Z","updated_at":"2025-08-17T13:15:24.223Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276216318,"owners_count":25604726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-21T08:46:54.282Z","updated_at":"2025-09-21T08:46:57.189Z","avatar_url":"https://github.com/celrenheit.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTest [![Build Status](https://img.shields.io/travis/celrenheit/htest.svg?style=flat-square)](https://travis-ci.org/celrenheit/htest) [![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](https://godoc.org/github.com/celrenheit/htest) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n\nA lightweight high-level abstractions for testing HTTP inspired by [supertest](https://github.com/visionmedia/supertest) built around [http.ResponseRecorder](https://golang.org/pkg/net/http/httptest/#ResponseRecorder)\n\n![Screenshot](https://raw.githubusercontent.com/celrenheit/htest/master/screenshot.png)\n\n# Install/Update\n\n```\n$ go get -u github.com/celrenheit/htest\n```\n\n# Usage\n\nLet's say that when we hit `/admin` we get a status code of `401 Unauthorized`, a response body of `You are not authorized` and a header of `foo=bar`\n\n```go\nmux := http.NewServeMux()\nmux.HandleFunc(\"/admin\", func(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"foo\", \"bar\")\n\tw.WriteHeader(http.StatusUnauthorized)\n\tfmt.Fprintf(w, \"You are not authorized\")\n})\n```\n\nWe can write a Test to test if our program behaves correctly\n\n```go\nfunc TestUnauthorized(t *testing.T) {\n  // We create a new instance for HTTPTester\n  // It requires a testing.T and an http.Handler as argument\n\th := htest.New(t, mux)\n\n  // We make assertions to the repsonse received\n\th.Get(\"/admin\").Do().\n\t\tExpectHeader(\"foo\", \"bar\").\n\t\tExpectStatus(http.StatusUnauthorized).\n\t\tExpectBody(\"You are not authorized\")\n}\n```\n\nh.Get returns a [Requester](https://godoc.org/github.com/celrenheit/htest#Requester) to be able to easily build your request.\nWe call the Do() to execute the request and get a [ResponseAsserter](https://godoc.org/github.com/celrenheit/htest#ResponseAsserter).\n\nThere are methods for each http methods in the [HTTPTester interface](https://godoc.org/github.com/celrenheit/htest#HTTPTester)\n\n\n# Building the request\n\nWe send some arbitrary data and set a header to the request. The response should have the same body and the same header value.\n\n```go\nfunc TestBuildingRequest(t *testing.T) {\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(\"/path\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"foo\", r.Header.Get(\"foo\"))\n\t\tio.Copy(w, r.Body)\n\t})\n\n\ttest := htest.New(t, mux)\n\n\ttest.Get(\"/path\").\n\t\t// Set a header to the request\n\t\tAddHeader(\"foo\", \"barbar\").\n\t\t// Send a string to the request's body\n\t\tSendString(\"my data\").\n\n\t\t// Executes the request\n\t\tDo().\n\n\t\t// The body sent should stay the same\n\t\tExpectBody(\"my data\").\n\t\t// The header sent should stay the same\n\t\tExpectHeader(\"foo\", \"barbar\")\n}\n```\n\n\n# Credits\n\n* https://github.com/go-errors/errors\n* https://github.com/stretchr/testify\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcelrenheit%2Fhtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcelrenheit%2Fhtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcelrenheit%2Fhtest/lists"}