{"id":37119327,"url":"https://github.com/smallinsky/mtf","last_synced_at":"2026-01-14T13:55:15.518Z","repository":{"id":55063293,"uuid":"179979878","full_name":"smallinsky/mtf","owner":"smallinsky","description":" Microservice Test Framework","archived":false,"fork":false,"pushed_at":"2023-05-11T20:39:25.000Z","size":88595,"stargazers_count":75,"open_issues_count":8,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-30T11:44:33.635Z","etag":null,"topics":["go","golang","grpc","testing"],"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/smallinsky.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":"2019-04-07T14:45:21.000Z","updated_at":"2024-04-19T17:03:45.000Z","dependencies_parsed_at":"2024-06-19T00:09:34.264Z","dependency_job_id":"50f91f4c-937c-4b3f-8c94-a084c01d5b95","html_url":"https://github.com/smallinsky/mtf","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/smallinsky/mtf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallinsky%2Fmtf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallinsky%2Fmtf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallinsky%2Fmtf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallinsky%2Fmtf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallinsky","download_url":"https://codeload.github.com/smallinsky/mtf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallinsky%2Fmtf/sbom","scorecard":{"id":832393,"data":{"date":"2025-08-11","repo":{"name":"github.com/smallinsky/mtf","commit":"b8cd898fb755d0cb1b2855d82a4baf30a5fc3286"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"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":"Code-Review","score":1,"reason":"Found 2/17 approved changesets -- score normalized to 1","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":"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":"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":"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":"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":"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"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: docker/ftp/Dockerfile:1","Warn: containerImage not pinned by hash: docker/ftp/Dockerfile:6: pin your Docker image by updating alpine:3.10 to alpine:3.10@sha256:451eee8bedcb2f029756dc3e9d73bab0e7943c1ac55cff3a4861c52a0fdd3e98","Warn: containerImage not pinned by hash: docker/pubsub_emulator/Dockerfile:1: pin your Docker image by updating google/cloud-sdk:alpine to google/cloud-sdk:alpine@sha256:64ad51eea4b6ded7be78ee2e017f661880355823c0e02afd5cc131346c69a122","Warn: containerImage not pinned by hash: docker/run_sut/Dockerfile:1: pin your Docker image by updating alpine:3.7 to alpine:3.7@sha256:8421d9a84432575381bfabd248f1eb56f3aa21d9d7cd2511583c68c9b7511d10","Warn: goCommand not pinned by hash: docker/ftp/Dockerfile:4","Info:   0 out of   4 containerImage dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"33 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0379 / GHSA-qq97-vm5h-rrhg","Warn: Project is vulnerable to: GHSA-hqxw-f8mx-cpmw","Warn: Project is vulnerable to: GHSA-qrqr-3x5j-2xw9","Warn: Project is vulnerable to: GHSA-j249-ghv5-7mxv","Warn: Project is vulnerable to: GHSA-6hwg-w5jg-9c6x","Warn: Project is vulnerable to: GO-2024-2521","Warn: Project is vulnerable to: GO-2024-2500 / GHSA-3fwx-pjgw-3558","Warn: Project is vulnerable to: GO-2024-2913 / GHSA-v994-f8vw-g7j4","Warn: Project is vulnerable to: GO-2024-2914 / GHSA-xmmx-7jpf-fx42","Warn: Project is vulnerable to: GO-2022-0390 / GHSA-2mm7-x5h6-5pvq","Warn: Project is vulnerable to: GO-2022-0985 / GHSA-rc4r-wh2q-q6c4","Warn: Project is vulnerable to: GO-2022-1107 / GHSA-vp35-85q5-9f25","Warn: Project is vulnerable to: GO-2023-1699 / GHSA-232p-vwff-86mp","Warn: Project is vulnerable to: GO-2023-1700 / GHSA-33pg-m6jh-5237","Warn: Project is vulnerable to: GO-2023-1701 / GHSA-6wrf-mxfj-pf5p","Warn: Project is vulnerable to: GHSA-jq35-85cj-fj4p","Warn: Project is vulnerable to: GHSA-mq39-4gv4-mvpx","Warn: Project is vulnerable to: GO-2024-2512 / GHSA-xw73-rw38-6vjc","Warn: Project is vulnerable to: GO-2025-3829 / GHSA-4vq8-7jfc-9cvp","Warn: Project is vulnerable to: GO-2022-0236 / GHSA-h86h-8ppg-mxmh","Warn: Project is vulnerable to: GO-2021-0238 / GHSA-83g2-8m93-v3w7","Warn: Project is vulnerable to: GO-2022-0288","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2025-3488 / GHSA-6v2p-p543-phr9"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T18:05:13.515Z","repository_id":55063293,"created_at":"2025-08-23T18:05:13.516Z","updated_at":"2025-08-23T18:05:13.516Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","golang","grpc","testing"],"created_at":"2026-01-14T13:55:14.940Z","updated_at":"2026-01-14T13:55:15.507Z","avatar_url":"https://github.com/smallinsky.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/smallinsky/mtf.svg?style=svg)](https://circleci.com/gh/smallinsky/mtf)[![Go Report Card](https://goreportcard.com/badge/github.com/smallinsky/mtf)](https://goreportcard.com/report/github.com/smallinsky/mtf)\n # Microservice Test Framework\n## Introduction\nThis Microservice Test Framework (MTF) allows in simple way to mock service dependencies and setup docker test environment comprehensive.\n\nSupported dependencies:\n* GRPC client/server communication\n* Google Cloud Pubsub\n* Google Cloud Storage (Partial - only bucket object Insert/Get operation)\n* FTP\n* HTTP/HTTPS integration\n* MySQL\n* Redis\n\nMTF framework aim to cut dependencies require to run your binary and execute tests but also focus on test readability.\n\n\n\n\n## Getting started\nTo begin using `MTF` framework you will need to define `TestMain` function and setup required environment used for binary that you would like to test further called `SUT` (System Under Test). To setup prerequisite dependency for your SUT the `framework.TestEnv` function should be invoked. `With...()` functions method chain allows to set up and configure dependency for SUT. Finally the `.Run()` chain method function starts the test.\n```go\nfunc TestMain(m *testing.M) {\n\tframework.TestEnv(m).\n\t\tWithSUT(framework.SutSettings{\n\t\t\tDir:   \"./service\", // dir with source files of system under test.\n\t\t\tPorts: []int{8001},\n\t\t\tEnvs: []string{\n\t\t\t\t\"ORACLE_ADDR=\" + framework.GetDockerHostAddr(8002),\n\t\t\t}}).\n\t\tWithRedis(framework.RedisSettings{\n\t\t\tPassword: \"test\",\n\t\t}).\n\t\tWithMySQL(framework.MysqlSettings{\n\t\t\tDatabaseName: \"test_db\",\n\t\t\tMigrationDir: \"./service/migrations\",\n\t\t\tPassword:     \"test\",\n\t\t}).Run()\n}\n```\n\nSuiteTest collects and groups collection of ports that allows to communicate with external mocked dependency.\n```go\ntype SuiteTest struct {\n\techoPort   *port.Port\n\thttpPort   *port.Port\n\toraclePort *port.Port\n}\n```\nPorts initialization should be done within Suite `Init(t *testing.T)` function.\n```go\nfunc (st *SuiteTest) Init(t *testing.T) {\n\tvar err error\n\tif st.echoPort, err = port.NewGRPCClientPort((*pb.EchoClient)(nil), \"localhost:8001\"); err != nil {\n\t\tt.Fatalf(\"failed to init grpc client port\")\n\t}\n\tst.httpPort = port.NewHTTPPort()\n\tif st.oraclePort, err = port.NewGRPCServerPort((*pbo.OracleServer)(nil), \":8002\"); err != nil {\n\t\tt.Fatalf(\"failed to init grpc oracle server\")\n\t}\n}\n```\n\n## Ports\nPort are used to communicate with dependencies by sending and receiving messages consistent.\n### GRPC Client/Server port `port.NewGRPCServerPort` `port.NewGRPCClientPort`\nGRPC ports allows mock whole grpc communication between client\u003c-\u003eSUT\u003c-\u003eOther GRPC service.\n\nServer grpc port initialization:\n```\noraclePort, err = port.NewGRPCServerPort((*pbo.OracleServer)(nil), \":8002\")\n```\n\nClient port initialization:\n```\nechoPort, err = port.NewGRPCClientPort((*pb.EchoClient)(nil), \"localhost:8001\")\n```\n\nExample of sut gprc method handler:\n```go\nfunc (s *server) AskOracle(ctx context.Context, req *pb.AskOracleRequest) (*pb.AskOracleResponse, error) {\n\tresp, err := s.OracleClient.AskDeepThought(ctx, \u0026pbo.AskDeepThoughtRequest{\n\t\tData: req.GetData(),\n\t})\n\tif err != nil {\n\t\tswitch status.Code(err) {\n\t\tcase codes.FailedPrecondition:\n\t\t\treturn \u0026pb.AskOracleResponse{\n\t\t\t\tData: \"Come back after seven and a half million years\",\n\t\t\t}, nil\n\t\tdefault:\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn \u0026pb.AskOracleResponse{\n\t\tData: resp.GetData(),\n\t}, nil\n}\n```\nTest GRPC message flow:\n```go\nfunc (st *SuiteTest) TestClientServerGRPC(t *testing.T) {\n\tst.echoPort.Send(t, \u0026pb.AskOracleRequest{\n\t\tData: \"Get answer for ultimate question of life the universe and everything\",\n\t})\n\tst.oraclePort.Receive(t, \u0026pbo.AskDeepThoughtRequest{\n\t\tData: \"Get answer for ultimate question of life the universe and everything\",\n\t})\n\tst.oraclePort.Send(t, \u0026pbo.AskDeepThoughtResponse{\n\t\tData: \"42\",\n\t})\n\tst.echoPort.Receive(t, \u0026pb.AskOracleResponse{\n\t\tData: \"42\",\n\t})\n}\n```\n```\n--- PASS: TestEchoService (0.75s)\n    --- PASS: TestEchoService/TestClientServerGRPC (0.01s)\nPASS\n```\nIf we change the handler body by adding additional text to AskOracleResponse.Date:\n```diff\n@@ -110,6 +110,6 @@ func (s *server) AskOracle(ctx context.Context, req *pb.AskOracleRequest) (*pb.A\n                return nil, err\n        }\n        return \u0026pb.AskOracleResponse{\n-               Data: resp.GetData(),\n+               Data: resp.GetData() + \"!!!\",\n        }, nil\n }\n```\nThe `echoPort.Receive(t, \u0026pb.AskOracleResponse{...}` call will log port mismatch\n```\n--- FAIL: TestEchoService/TestClientServerGRPC (0.01s)\nport.go:89: Failed to receive *echo.AskOracleResponse:\n     deep equal:\n     got:'{\n     \"data\": \"42!!!!\"\n    }'\n     exp: '{\n     \"data\": \"42\"\n    }'\n    : match not eq\n```\nMock GRPC error response:\n```go\nfunc (st *SuiteTest) TestClientServerGRPCError(t *testing.T) {\n\tst.echoPort.Send(t, \u0026pb.AskOracleRequest{\n\t\tData: \"Get answer for ultimate question of life the universe and everything\",\n\t})\n\tst.oraclePort.Receive(t, \u0026pbo.AskDeepThoughtRequest{\n\t\tData: \"Get answer for ultimate question of life the universe and everything\",\n\t})\n\tst.oraclePort.Send(t, \u0026port.GRPCErr{\n\t\tErr: status.Errorf(codes.FailedPrecondition, \"Deepthought error\"),\n\t})\n\tst.echoPort.Receive(t, \u0026pb.AskOracleResponse{\n\t\tData: \"Come back after seven and a half million years\",\n\t})\n}\n```\n## HTTP/HTTPS Port `port.NewHTTPPort()`\nHTTP port allows to test external http endpoint integration by matching SUT's http requests and sending back custom shape responses.\n\n```go\nfunc (st *SuiteTest) TestHTTP(t *testing.T) {\n\tst.httpPort.Receive(t, \u0026port.HTTPRequest{\n\t\tBody:   []byte{},\n\t\tMethod: \"GET\",\n\t\tHost:   \"example.com\",\n\t\tURL:    \"/urlpath\",\n\t})\n\n\tst.httpPort.Send(t, \u0026port.HTTPResponse{\n\t\tBody:   []byte(`{\"value\":{\"joke\":\"42\"}}`),\n\t\tStatus: http.StatusOK,\n\t})\n}\n```\n\n### GRPC and HTTPS with TLS support\n\nThe `framework.WithTLS(framework.TLSSettings{Hosts: []string{\"customdomain.com\"})` chain method of `framework.TestEnv` allows to setting custom DNSNames that will be added to TLS.\nIn order to create grpc TLS server or client the port `port.WithTLS` options should be pass to NewGRPCServerPort or NewGRPCClientPort port function.\nUnder the hood the mtf framework will create cert key pair in `/tmp/mtf/` that will be propagated to dependencies during test execution.\n\n\n### Match `mtf/match`\nMatch only respnse message type:\n```go\nechoPort.Receive(t, match.Type(\u0026pb.AskOracleResponse{})\n```\nMatch response by custom function:\n```go\nechoPort.Receive(t, match.Fn(func(resp *pb.AskGoogleResponse) {\n\t\tif got, want := len(resp.GetData()), 2; got != want {\n\t\t\tt.Fatalf(\"data len mismatch, got: %v want: %v\", got, want)\n\t\t}\n\t}))\n```\nMatch response GRPC Error status code:\n```\nechoPort.Receive(t, match.GRPCStatusCode(codes.Internal))\n```\n## MTF Tests execution\nRight now MTF framework does not support parallel test execution and to prevent simultaneously test run passing the  `-p 1` flag to `go test` command is required.  \n### Run tests examples:\n```bash\ngo test ./example/... -p 1 --rebuild_binary=true  -tags=mtf\n```\n\n### Test Environment preparation phase\nAt first run the mtf will download docker images dependency needed to prepare and run test environment:\n```\n=== PREPARING TEST ENV\n  - Starting [REDIS Component] -  1.601356005s\n  - Starting [MYSQL Component] -  50.75908ms\n  - Starting [MIGRATE Component] -  805.090778ms\n  - Starting [SUT Component] -  5.895084273s\n=== TEST RUN DONE - 11.863770827s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallinsky%2Fmtf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallinsky%2Fmtf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallinsky%2Fmtf/lists"}