{"id":18410059,"url":"https://github.com/isomorphic-git/git-http-mock-server","last_synced_at":"2025-04-07T09:34:33.162Z","repository":{"id":66261847,"uuid":"147604754","full_name":"isomorphic-git/git-http-mock-server","owner":"isomorphic-git","description":"Clone and push to git repository test fixtures over HTTP.","archived":false,"fork":false,"pushed_at":"2023-12-08T09:20:36.000Z","size":253,"stargazers_count":16,"open_issues_count":6,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-24T19:33:35.957Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/isomorphic-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-09-06T02:13:49.000Z","updated_at":"2024-03-22T22:26:02.000Z","dependencies_parsed_at":"2024-01-23T21:24:31.512Z","dependency_job_id":"1578c6bd-a2ca-4a2b-ac1e-e9028ccbbada","html_url":"https://github.com/isomorphic-git/git-http-mock-server","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isomorphic-git%2Fgit-http-mock-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isomorphic-git%2Fgit-http-mock-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isomorphic-git%2Fgit-http-mock-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isomorphic-git%2Fgit-http-mock-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isomorphic-git","download_url":"https://codeload.github.com/isomorphic-git/git-http-mock-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223277179,"owners_count":17118503,"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","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":"2024-11-06T03:28:52.767Z","updated_at":"2024-11-06T03:28:53.832Z","avatar_url":"https://github.com/isomorphic-git.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-http-mock-server / git-ssh-mock-server\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fisomorphic-git%2Fgit-http-mock-server.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fisomorphic-git%2Fgit-http-mock-server?ref=badge_shield)\n\nClone and push to git repository test fixtures over HTTP or SSH.\n\n## What it does\n\nIt is similar to [`git-http-server`](https://npm.im/git-http-server) but designed for test cases only.\nIt uses copy-on-write so that pushing to the repo doesn't actually alter the repo.\n\nRun in a directory full of bare git repositories, `git-http-mock-server` will serve those repos using the\nnative `git-http-backend` process built into `git` (which needs to be installed on the machine).\n\nYou can then:\n- run tests that clone or push to those git repositories (regardless of whether Github is down :wink:).\n- run those tests in parallel without them interfering with each other.\n\nGit hooks such as `hooks/update` and `hooks/post-receive` are automatically supported.\n\nIt also supports HTTP Basic Auth password protection of repos so you can test how your code handles 401 errors.\n\nUsing `isomorphic-git` and testing things from browsers? Fear not, `git-http-mock-server` includes appropriate CORS headers.\n\n`git-ssh-mock-server` is similar, but because authentication happens before the client can say which repo\nthey are interested in, the authentication can't be customized per repository.\nBy default it allows anonymous SSH access. You can disable anonymous access and activate password authentication by setting the `GIT_SSH_MOCK_SERVER_PASSWORD` evironment variable.\n(When password auth is activated, any username will work as long as the password matches the environment variable.)\nAlternatively, you can set the `GIT_SSH_MOCK_SERVER_PUBKEY` environment variable to true to disable anonymous access and activate Public Key authentication. What key to use is explained in detail later in this document.\n\n## How to use\n\n```sh\nnpm install --save-dev git-http-mock-server\n```\n\nNow `cd` to a directory in which you have some bare git repos and run this server:\n\n```sh\n\u003e cd __fixtures__\n\u003e ls\ntest-repo1.git    test-repo2.git   imaginatively-named-repo.git\n\u003e git-http-mock-server\n```\n\nNow in another shell, clone and push away...\n```sh\n\u003e git clone http://localhost:8174/test-repo1.git\n\u003e git clone http://localhost:8174/test-repo2.git\n\u003e git clone http://localhost:8174/imaginatively-named-repo.git\n```\n\nTo do the same thing but with SSH\n\n```sh\n\u003e cd __fixtures__\n\u003e ls\ntest-repo1.git    test-repo2.git   imaginatively-named-repo.git\n\u003e git-ssh-mock-server\n```\n\nNow in another shell,\n```sh\n\u003e git clone ssh://localhost:2222/imaginatively-named-repo.git\n```\n\n## Run in the background\n\nIf you want to reuse the same shell (as part of a shell script, for example)\nyou can run the server as a daemon in the background:\n\n```sh\n\u003e git-http-mock-server start\n\u003e # do stuff\n\u003e git-http-mock-server stop\n```\n\nJust be sure to run `start` and `stop` from the same working directory.\n(The `start` command writes the PID of the server to `./git-http-mock-server.pid` so that the `stop` command knows what process to kill.)\n\nSame thing for SSH:\n\n```sh\n\u003e git-ssh-mock-server start\n\u003e # do stuff\n\u003e git-ssh-mock-server stop\n```\n\n### Environment Variables\n\n- `GIT_HTTP_MOCK_SERVER_PORT` default is 8174 (to be compatible with [git-http-server](https://github.com/bahamas10/node-git-http-server))\n- `GIT_HTTP_MOCK_SERVER_ROUTE` default is `/`\n- `GIT_HTTP_MOCK_SERVER_ROOT` default is `process.cwd()`\n- `GIT_HTTP_MOCK_SERVER_ALLOW_ORIGIN` default is `*` (used for CORS)\n- `GIT_SSH_MOCK_SERVER_PORT` default is 2222\n- `GIT_SSH_MOCK_SERVER_ROUTE` default is `/`\n- `GIT_SSH_MOCK_SERVER_ROOT` default is `process.cwd()`\n- `GIT_SSH_MOCK_SERVER_PASSWORD` activate Password Authentication and use this password (leave blank to allow anonymous SSH access.)\n- `GIT_SSH_MOCK_SERVER_PUBKEY` activate PubKey Authentication using the self-generated keypair (leave blank to allow anonymous SSH access.)\n\n### .htpasswd support (http-only)\n\nYou can place an Apache-style `.htpasswd` file in a bare repo to protect it with Basic Authentication.\n\n```sh\n\u003e cd __fixtures__/test-repo1.git\n\u003e htpasswd -cb .htpasswd testuser testpassword\nAdding password for user testuser.\n\u003e cat .htpasswd\ntestuser:$apr1$BRdvH4Mu$3HrpeyBrWiS88GcSPidgq/\n```\n\nIf you don't have `htpasswd` on your machine, you can use [htpasswd](https://npm.im/htpasswd) which is\na cross-platform Node implementation of `htpasswd`.\n\n### Public Key Auth support (ssh-only)\n\n`git-ssh-mock-server` generates its own keypair using the system's native `ssh-keygen` the first time it's run,\nin order to create encrypted SSH connections.\nThis key can be used to authenticate with the server as well!\n\n1. Run `GIT_SSH_MOCK_SERVER_PUBKEY=true git-ssh-mock-server`\n2. Try cloning (e.g. `git clone ssh://localhost:2222/imaginatively-named-repo.git`). It shouldn't work.\n2. Run `git-ssh-mock-server exportKeys` which will copy the key files to `./id_rsa` and `./id_rsa.pub` in the working directory with the correct file permissions (`600`).\n3. Run `ssh-add ./id_rsa`\n4. Now try cloning. It works!\n5. To clear the key from the ssh-agent, use `ssh-add -d ./id_rsa`\n\nYou can use `GIT_SSH_MOCK_SERVER_PUBKEY` and `GIT_SSH_MOCK_SERVER_PASSWORD` together, but using either one disables anonymous SSH access.\n\n## Dependencies\n\n- [basic-auth](https://ghub.io/basic-auth): node.js basic auth parser\n- [buffer-equal-constant-time](https://ghub.io/buffer-equal-constant-time): Constant-time comparison of Buffers\n- [chalk](https://ghub.io/chalk): Terminal string styling done right\n- [fixturez](https://ghub.io/fixturez): Easily create and maintain test fixtures in the file system\n- [git-http-backend](https://ghub.io/git-http-backend): serve a git repository over http\n- [htpasswd-js](https://ghub.io/htpasswd-js): Pure JS htpasswd authentication\n- [ssh2](https://ghub.io/ssh2): SSH2 client and server modules written in pure JavaScript for node.js\n\noriginally inspired by '[git-http-server](https://github.com/bahamas10/node-git-http-server)'\n\n## License\n\nMIT\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fisomorphic-git%2Fgit-http-mock-server.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fisomorphic-git%2Fgit-http-mock-server?ref=badge_large)\n\n## Changelog\n\n1.2.0 - add SSH server\n1.1.0 - support running in background and CORS headers\n1.0.0 - Initial release","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisomorphic-git%2Fgit-http-mock-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisomorphic-git%2Fgit-http-mock-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisomorphic-git%2Fgit-http-mock-server/lists"}