{"id":15714349,"url":"https://github.com/ygalblum/slack-server-mock","last_synced_at":"2025-11-05T03:03:56.271Z","repository":{"id":247437858,"uuid":"823320370","full_name":"ygalblum/slack-server-mock","owner":"ygalblum","description":"Mock Slack HTTP and WebSocker server for sub-system testing purposes","archived":false,"fork":false,"pushed_at":"2025-02-28T20:02:51.000Z","size":71,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T19:46:44.159Z","etag":null,"topics":["mock-server","slack","testing-tool"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ygalblum.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-02T20:11:03.000Z","updated_at":"2025-02-28T20:02:55.000Z","dependencies_parsed_at":"2024-10-24T11:58:32.457Z","dependency_job_id":"3fdef9d8-5269-43c2-8d5e-47d899217e1c","html_url":"https://github.com/ygalblum/slack-server-mock","commit_stats":null,"previous_names":["ygalblum/slack-server-mock"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ygalblum%2Fslack-server-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ygalblum%2Fslack-server-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ygalblum%2Fslack-server-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ygalblum%2Fslack-server-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ygalblum","download_url":"https://codeload.github.com/ygalblum/slack-server-mock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251780424,"owners_count":21642772,"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":["mock-server","slack","testing-tool"],"created_at":"2024-10-03T21:36:16.202Z","updated_at":"2025-11-05T03:03:51.235Z","avatar_url":"https://github.com/ygalblum.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slack Server Mock\nSlack server mock is intended to be used for sub-system testing of Slack applications.\n\n## Running the Server\n\n### Required files\n\n#### settings.yaml\nCreate a settings.yaml file based on the [sample file](./settings.yaml).\n\n#### Channels file\nIf you wish to return a list of channels, create a JSON file with an array of channel objects.\nAt minimum, each entry must have a name and an ID.\n\nIn the `settings.yaml` file, set `slack_server.channels_path` to the location of the file.\n\n#### Response Data Configuration\nThe `settings.yaml` file contains a `response_data` section that allows you to configure the responses of the server for specific endpoints.\n\nThe responses definied in the `response_data` section are JSON files that contain the response data for the endpoint.\n\nThe directory structure should be as follows:\n```\nresponse_data_path\n  / endpoint_name\n    / ID-VALUE.json\n```\nSee the `test/responses` directory for examples.\n\nFor endpoints with multiple query parameters, the file should be named with the query parameters separated by a dash. For example, `conversations.history/channel-ts.json`.\n\nIn the `settings.yaml` file, set the `response_data` section to the base path for the JSON files.\n\n### Using Poetry\n\n#### Prerequisites\nInstall [poetry](https://python-poetry.org/docs/)\n\n#### Installation\n- Download the code and change to the downloaded directory:\n  ```bash\n  git clone https://github.com/ygalblum/slack-server-mock.git\n  cd slack-server-mock\n  ```\n- Install all the requirements using poetry:\n  ```bash\n  poetry install --no-root\n  ```\n- Run the application:\n  ```bash\n  poetry run python -m slack_server_mock\n  ```\n\n### Using a Podman/Docker\n\nThe server is published in a container image on [quay](https://quay.io/repository/yblum/slack_server_mock).\n\n#### Running the latest version\n```bash\npodman run --rm -it -d --name slack_server_mock --publish 3001:3001 --publish 8080:8080 --publish 8888:8888 --volume ${PWD}/settings.yaml:/app/settings.yaml:z quay.io/yblum/slack_server_mock:latest\n```\n\n#### Channels file\nIf you are using a channels file, make sure to mount it into the container as well.\n\n## Configure your Slack application\nIn order to make your Slack application connect with the mock server you need to override its `base_url`.\n\n### Socket mode\nInstead of:\n```python\nhandler = SocketModeHandler(\n    App(token=BOT_TOKEN),\n    APP_TOKEN\n)\n```\n\nUse:\n```python\nhandler = SocketModeHandler(\n    app=App(\n        client=WebClient(\n            token=BOT_TOKEN,\n            base_url=\"http://localhost:8888\"\n        )\n    ),\n    app_token=settings.slackbot.app_token\n)\n```\n\n## Interacting with the application\nThe mock server provides an endpoint to send a message to the application,\nwait for the application response and return the accumulated ephemeral messages (if sent) and the response.\n\n### Message payload\nThe request payload is a JSON with the key `message` whose value is a string\n\n### Response payload\nThe response payload is a JSON with two keys:\n\n- `ephemeral`: List of strings. All accumulated ephemeral message\n- `response`: string. The application's response\n\n### Example\nSend a message using `curl` and see the response:\n```bash\n$ curl http://localhost:8080/message -d'{\"message\": \"hello\"}'\n{\"answer\": \"Hello to you too\", \"ephemeral\": [\"I'll be right with you\"]}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fygalblum%2Fslack-server-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fygalblum%2Fslack-server-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fygalblum%2Fslack-server-mock/lists"}