74 Commits
v2.0.3 ... main

Author SHA1 Message Date
c9bb065696 updated port >1024 2024-01-27 21:03:09 -07:00
Łukasz Budnik
906be51244 Merge pull request #84 from lukaszbudnik/ping-with-timeout
implemented support for custom timeout parameter for ping/reachability analyzer
2023-11-17 07:03:50 +01:00
Łukasz Budnik
5651f7227f implemented support for custom timeout parameter for ping/reachability analyzer 2023-11-17 07:01:55 +01:00
Łukasz Budnik
bfb0a19737 Merge pull request #83 from lukaszbudnik/ping-reachability-analyzer
implemented ping and reachability analyzer functionality
2023-11-15 20:13:48 +01:00
Łukasz Budnik
f6cd6893fd fixed typo 2023-11-15 20:12:25 +01:00
Łukasz Budnik
1d44df4ba9 implemented ping and reachibility analyzer functionality 2023-11-15 20:06:09 +01:00
Łukasz Budnik
3ccac4010f Merge pull request #77 from lukaszbudnik/dependabot/docker/golang-1.21-alpine
Bump golang from 1.19-alpine to 1.21-alpine
2023-11-15 10:27:08 +01:00
dependabot[bot]
35bf0249ad Bump golang from 1.19-alpine to 1.21-alpine
Bumps golang from 1.19-alpine to 1.21-alpine.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-15 09:21:28 +00:00
Łukasz Budnik
046b2040c3 Merge pull request #71 from lukaszbudnik/dependabot/docker/alpine-3.18
Bump alpine from 3.17 to 3.18
2023-11-15 10:20:45 +01:00
Łukasz Budnik
6d914f6e51 Merge branch 'main' into dependabot/docker/alpine-3.18 2023-11-15 10:17:41 +01:00
Łukasz Budnik
bf6a62c004 Merge pull request #76 from lukaszbudnik/dependabot/go_modules/github.com/gorilla/handlers-1.5.2
Bump github.com/gorilla/handlers from 1.5.1 to 1.5.2
2023-11-15 08:06:27 +01:00
dependabot[bot]
4a5cc84585 Bump github.com/gorilla/handlers from 1.5.1 to 1.5.2
Bumps [github.com/gorilla/handlers](https://github.com/gorilla/handlers) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/gorilla/handlers/releases)
- [Commits](https://github.com/gorilla/handlers/compare/v1.5.1...v1.5.2)

---
updated-dependencies:
- dependency-name: github.com/gorilla/handlers
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-15 07:03:38 +00:00
Łukasz Budnik
5cc4cc573f Merge pull request #75 from lukaszbudnik/dependabot/go_modules/github.com/gorilla/mux-1.8.1
Bump github.com/gorilla/mux from 1.8.0 to 1.8.1
2023-11-15 07:52:51 +01:00
Łukasz Budnik
be35c96a78 Merge branch 'main' into dependabot/go_modules/github.com/gorilla/mux-1.8.1 2023-11-15 07:51:29 +01:00
Łukasz Budnik
206a37ccfb Merge pull request #79 from lukaszbudnik/dependabot/github_actions/docker/login-action-3
Bump docker/login-action from 2 to 3
2023-11-14 22:07:24 +01:00
dependabot[bot]
e9a1cb3340 Bump docker/login-action from 2 to 3
Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-14 21:00:20 +00:00
Łukasz Budnik
270c92f038 Merge pull request #78 from lukaszbudnik/dependabot/github_actions/docker/metadata-action-5
Bump docker/metadata-action from 4 to 5
2023-11-14 21:59:30 +01:00
dependabot[bot]
d8e6d8a770 Bump docker/metadata-action from 4 to 5
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4 to 5.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Upgrade guide](https://github.com/docker/metadata-action/blob/master/UPGRADE.md)
- [Commits](https://github.com/docker/metadata-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-14 20:49:27 +00:00
Łukasz Budnik
dbe56d6684 Merge pull request #80 from lukaszbudnik/dependabot/github_actions/docker/build-push-action-5
Bump docker/build-push-action from 4 to 5
2023-11-14 21:48:36 +01:00
dependabot[bot]
fe4ccaac6d Bump docker/build-push-action from 4 to 5
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-14 20:46:43 +00:00
Łukasz Budnik
593c42fba7 Merge pull request #81 from lukaszbudnik/dependabot/github_actions/actions/checkout-4.1.1
Bump actions/checkout from 3.5.3 to 4.1.1
2023-11-14 21:45:46 +01:00
Łukasz Budnik
d8a01b4f77 Merge branch 'main' into dependabot/github_actions/actions/checkout-4.1.1 2023-11-14 21:44:58 +01:00
Łukasz Budnik
0245cda959 Merge pull request #82 from lukaszbudnik/updating-deprecated-methods-fields
updated deprecated API
2023-11-14 18:41:18 +01:00
dependabot[bot]
20a8b270e8 Bump actions/checkout from 3.5.3 to 4.1.1
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 4.1.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.5.3...v4.1.1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-14 17:36:20 +00:00
Łukasz Budnik
2a3c6806b5 updated deprecated API to new API 2023-11-14 18:35:59 +01:00
dependabot[bot]
b207586411 Bump github.com/gorilla/mux from 1.8.0 to 1.8.1
Bumps [github.com/gorilla/mux](https://github.com/gorilla/mux) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/gorilla/mux/releases)
- [Commits](https://github.com/gorilla/mux/compare/v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/gorilla/mux
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-14 17:28:36 +00:00
Łukasz Budnik
ac599cd5d3 Merge pull request #73 from lukaszbudnik/dependabot/go_modules/github.com/stretchr/testify-1.8.4
Bump github.com/stretchr/testify from 1.8.2 to 1.8.4
2023-11-14 11:49:38 +01:00
Łukasz Budnik
f35c750b60 Merge branch 'main' into dependabot/go_modules/github.com/stretchr/testify-1.8.4 2023-11-14 11:45:04 +01:00
Łukasz Budnik
1f120f6f61 Merge pull request #74 from lukaszbudnik/dependabot/github_actions/actions/checkout-3.5.3
Bump actions/checkout from 3.5.1 to 3.5.3
2023-11-14 11:44:24 +01:00
dependabot[bot]
0697b7feca Bump actions/checkout from 3.5.1 to 3.5.3
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.1 to 3.5.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.5.1...v3.5.3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-09 17:56:57 +00:00
dependabot[bot]
35f72dbaad Bump github.com/stretchr/testify from 1.8.2 to 1.8.4
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.2...v1.8.4)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-30 17:56:55 +00:00
dependabot[bot]
6c09411f4e Bump alpine from 3.17 to 3.18
Bumps alpine from 3.17 to 3.18.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-10 17:58:14 +00:00
Łukasz Budnik
26a1d3c829 Merge pull request #69 from lukaszbudnik/dependabot/github_actions/actions/checkout-3.5.1
Bump actions/checkout from 3.4.0 to 3.5.1
2023-04-13 07:35:30 +02:00
dependabot[bot]
3a3b2df8b7 Bump actions/checkout from 3.4.0 to 3.5.1
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.4.0 to 3.5.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.4.0...v3.5.1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-12 17:57:39 +00:00
Łukasz Budnik
04824c18f0 Merge pull request #66 from lukaszbudnik/dependabot/github_actions/actions/setup-go-4
Bump actions/setup-go from 3 to 4
2023-03-18 08:17:14 +01:00
dependabot[bot]
2f942c3ee7 Bump actions/setup-go from 3 to 4
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-18 07:09:04 +00:00
Łukasz Budnik
40780e79ee Merge pull request #63 from lukaszbudnik/dependabot/github_actions/docker/build-push-action-4
Bump docker/build-push-action from 3 to 4
2023-03-18 08:08:28 +01:00
dependabot[bot]
2268784739 Bump docker/build-push-action from 3 to 4
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3 to 4.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-18 06:42:47 +00:00
Łukasz Budnik
53bbc21af9 Merge pull request #67 from lukaszbudnik/dependabot/github_actions/actions/checkout-3.4.0
Bump actions/checkout from 3.3.0 to 3.4.0
2023-03-18 07:42:12 +01:00
dependabot[bot]
490e0e43f0 Bump actions/checkout from 3.3.0 to 3.4.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.3.0...v3.4.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-16 17:57:13 +00:00
Łukasz Budnik
68691a718a Merge pull request #65 from lukaszbudnik/dependabot/go_modules/github.com/stretchr/testify-1.8.2
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2
2023-03-04 20:09:54 +01:00
dependabot[bot]
605de812c3 Bump github.com/stretchr/testify from 1.8.1 to 1.8.2
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.1 to 1.8.2.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.1...v1.8.2)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-27 17:59:41 +00:00
Łukasz Budnik
48cb758883 Merge pull request #62 from lukaszbudnik/upgrade-docker-dependencies-add-integration-test
upgraded docker containers for golang and alpine
2023-01-08 20:39:59 +01:00
Łukasz Budnik
196306d131 correct bash if-then-else syntax 2023-01-08 20:36:31 +01:00
Łukasz Budnik
c5415206e6 upgraded docker containers for golang and alpine, added simple integration test 2023-01-08 20:33:08 +01:00
Łukasz Budnik
66b4078631 Merge pull request #61 from lukaszbudnik/dependabot/github_actions/actions/checkout-3.3.0
Bump actions/checkout from 3.1.0 to 3.3.0
2023-01-08 17:43:12 +01:00
dependabot[bot]
d14e46e839 Bump actions/checkout from 3.1.0 to 3.3.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.3.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.1.0...v3.3.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-05 17:01:35 +00:00
Łukasz Budnik
21ffd8ef65 Merge pull request #57 from lukaszbudnik/dependabot/go_modules/github.com/stretchr/testify-1.8.1
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1
2022-10-28 17:47:17 +02:00
dependabot[bot]
75cd57556b Bump github.com/stretchr/testify from 1.8.0 to 1.8.1
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-24 17:49:28 +00:00
Łukasz Budnik
27d54a67c5 Merge pull request #46 from lukaszbudnik/dependabot/github_actions/docker/build-push-action-3
Bump docker/build-push-action from 2 to 3
2022-10-07 22:56:46 +02:00
dependabot[bot]
394b6c6b19 Bump docker/build-push-action from 2 to 3
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2 to 3.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-07 20:52:09 +00:00
Łukasz Budnik
572a661570 Merge pull request #45 from lukaszbudnik/dependabot/github_actions/docker/metadata-action-4
Bump docker/metadata-action from 3 to 4
2022-10-07 22:51:34 +02:00
dependabot[bot]
ae2c5d1f80 Bump docker/metadata-action from 3 to 4
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 3 to 4.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Upgrade guide](https://github.com/docker/metadata-action/blob/master/UPGRADE.md)
- [Commits](https://github.com/docker/metadata-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-07 20:49:08 +00:00
Łukasz Budnik
0b8223504c Merge pull request #48 from lukaszbudnik/dependabot/github_actions/actions/setup-go-3.2.0
Bump actions/setup-go from 2 to 3.2.0
2022-10-07 22:48:34 +02:00
dependabot[bot]
d10a176e53 Bump actions/setup-go from 2 to 3.2.0
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.2.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3.2.0)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-07 20:44:58 +00:00
Łukasz Budnik
e8636e09ac Merge pull request #53 from lukaszbudnik/dependabot/go_modules/github.com/stretchr/testify-1.8.0
Bump github.com/stretchr/testify from 1.7.0 to 1.8.0
2022-10-07 22:44:00 +02:00
dependabot[bot]
109e665451 Bump github.com/stretchr/testify from 1.7.0 to 1.8.0
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-07 20:32:54 +00:00
Łukasz Budnik
33c6293042 Merge pull request #55 from lukaszbudnik/dependabot/docker/alpine-3.16.2
Bump alpine from 3.14.2 to 3.16.2
2022-10-07 22:31:53 +02:00
dependabot[bot]
6c93e2987b Bump alpine from 3.14.2 to 3.16.2
Bumps alpine from 3.14.2 to 3.16.2.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-07 20:29:23 +00:00
Łukasz Budnik
cfdeef0e2a Merge pull request #44 from lukaszbudnik/dependabot/github_actions/docker/login-action-2
Bump docker/login-action from 1 to 2
2022-10-07 22:28:26 +02:00
dependabot[bot]
1842453288 Bump docker/login-action from 1 to 2
Bumps [docker/login-action](https://github.com/docker/login-action) from 1 to 2.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-07 20:26:52 +00:00
Łukasz Budnik
9fdfd5cb17 Merge pull request #56 from lukaszbudnik/dependabot/github_actions/actions/checkout-3.1.0
Bump actions/checkout from 2.4.0 to 3.1.0
2022-10-07 22:26:15 +02:00
dependabot[bot]
62d92811ce Bump actions/checkout from 2.4.0 to 3.1.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.1.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.4.0...v3.1.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-04 17:07:54 +00:00
Łukasz Budnik
5e0380377f Merge pull request #31 from lukaszbudnik/dependabot/docker/golang-1.17.3-alpine3.13
Bump golang from 1.17.2-alpine3.13 to 1.17.3-alpine3.13
2021-11-05 18:28:09 +01:00
dependabot[bot]
669c88abce Bump golang from 1.17.2-alpine3.13 to 1.17.3-alpine3.13
Bumps golang from 1.17.2-alpine3.13 to 1.17.3-alpine3.13.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-05 17:09:55 +00:00
Łukasz Budnik
46ce22d8ec Merge pull request #30 from lukaszbudnik/dependabot/github_actions/actions/checkout-2.4.0
Bump actions/checkout from 2.3.5 to 2.4.0
2021-11-03 18:20:39 +01:00
dependabot[bot]
6e8531123f Bump actions/checkout from 2.3.5 to 2.4.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.5 to 2.4.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.3.5...v2.4.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-03 17:07:22 +00:00
Łukasz Budnik
f651a27580 Merge pull request #29 from lukaszbudnik/dependabot/github_actions/actions/checkout-2.3.5
Bump actions/checkout from 2.3.4 to 2.3.5
2021-10-16 08:35:46 +02:00
dependabot[bot]
900118758f Bump actions/checkout from 2.3.4 to 2.3.5
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.4 to 2.3.5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.3.4...v2.3.5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-15 17:07:06 +00:00
Łukasz Budnik
2da157319c Merge pull request #26 from lukaszbudnik/dependabot/docker/alpine-3.14.2
Bump alpine from 3.14.1 to 3.14.2
2021-10-08 19:51:42 +02:00
dependabot[bot]
1f0946a0b1 Bump alpine from 3.14.1 to 3.14.2
Bumps alpine from 3.14.1 to 3.14.2.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-08 17:50:47 +00:00
Łukasz Budnik
1b5234d37c Merge pull request #28 from lukaszbudnik/dependabot/docker/golang-1.17.2-alpine3.13
Bump golang from 1.17.0-alpine3.13 to 1.17.2-alpine3.13
2021-10-08 19:50:11 +02:00
dependabot[bot]
b334dcfcea Bump golang from 1.17.0-alpine3.13 to 1.17.2-alpine3.13
Bumps golang from 1.17.0-alpine3.13 to 1.17.2-alpine3.13.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-08 17:06:54 +00:00
Łukasz Budnik
f09931b33a Create FUNDING.yml 2021-09-01 12:56:16 +02:00
12 changed files with 483 additions and 51 deletions

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
# These are supported funding model platforms
github: [lukaszbudnik]

View File

@@ -7,6 +7,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4.1.1
- name: Build the Docker image
run: docker build . --file Dockerfile --tag yosoy-local:$(date +%s)
run: docker build . --file Dockerfile --tag yosoy-local:latest
- name: Run simple integration test
run: |
docker run -p 3333:80 yosoy-local:latest > yosoy.log &
sleep 5
RESULT=$(curl -s -X DELETE -H 'x-api-key: abc123' 'http://0.0.0.0:3333/sample/path?with=params')
echo "$RESULT"
if [[ $RESULT =~ '"method":"DELETE"' ]]
then
echo 'Test successful'
exit 0
else
echo 'Test failure'
exit 1
fi

View File

@@ -15,16 +15,16 @@ jobs:
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1
- name: Log in to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -32,7 +32,7 @@ jobs:
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: |
lukasz/yosoy
@@ -44,7 +44,7 @@ jobs:
type=semver,pattern={{major}}
- name: Build and push Docker images
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true

View File

@@ -6,12 +6,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4.1.1
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: 1.19
- name: Build
run: go build -v ./...

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
debug.test
cover.out
yosoy

View File

@@ -1,15 +1,19 @@
FROM golang:1.17.0-alpine3.13 as builder
FROM golang:1.21-alpine as builder
LABEL maintainer="Łukasz Budnik lukasz.budnik@gmail.com"
# install prerequisites
RUN apk update && apk add git
# build yosoy
ADD . /go/yosoy
RUN go env -w GOPROXY=direct
RUN cd /go/yosoy && go build
FROM alpine:3.14.1
FROM alpine:3.18
COPY --from=builder /go/yosoy/yosoy /bin
# register entrypoint
ENTRYPOINT ["yosoy"]
EXPOSE 80
EXPOSE 8080

View File

@@ -1,15 +1,18 @@
# yosoy ![Go](https://github.com/lukaszbudnik/yosoy/workflows/Go/badge.svg) ![Docker](https://github.com/lukaszbudnik/yosoy/workflows/Docker%20Image%20CI/badge.svg)
yosoy is a HTTP service for stubbing and prototyping distributed applications. It is a service which will introduce itself to the caller and print some useful information about its environment. "Yo soy" in español means "I am".
yosoy is an HTTP service for stubbing and prototyping distributed applications. It is a service that introduces itself to the caller and prints useful information about its runtime environment.
yosoy is extremely useful when creating a distributed application stub and you need to see more meaningful responses than a default nginx welcome page.
yosoy is extremely useful when creating a stub for a distributed application, as it provides more meaningful responses than, for example, a default nginx welcome page. Further, yosoy incorporates a built-in reachability analyzer to facilitate troubleshooting connectivity issues in distributed systems. A dedicated reachability analyzer endpoint validates network connectivity between yosoy and remote endpoints.
Typical use cases include:
- testing HTTP routing & ingress
- testing HTTP load balancing
- testing HTTP caching
- stubbing and prototyping distributed applications
- Testing HTTP routing and ingress
- Testing HTTP load balancing
- Testing HTTP caching
- Executing reachability analysis
- Stubbing and prototyping distributed applications
"Yo soy" means "I am" in Spanish.
## API
@@ -31,19 +34,25 @@ yosoy responds to all requests with a JSON containing the information about:
- Env variables if `YOSOY_SHOW_ENVS` is set to `true`, `yes`, `on`, or `1`
- Files' contents if `YOSOY_SHOW_FILES` is set to a comma-separated list of (valid) files
Checkout out [Sample JSON response](#sample-json-response) below to see how useful yosoy is when troubleshooting/stubbing/prototyping distributed applications.
Check [Sample JSON response](#sample-json-response) to see how you can use yosoy for stubbing/prototyping/troubleshooting distributed applications.
## ping/reachability analyzer
yosoy includes a simple ping/reachability analyzer. You can use this functionality when prototyping distributed systems to validate whether a given component can reach a specific endpoint. yosoy exposes a dedicated `/_/yosoy/ping` endpoint which accepts the following 4 query parameters:
* `h` - required - hostname of the endpoint
* `p` - required - port of the endpoint
* `n` - optional - network, all valid Go networks are supported (including the most popular ones like `tcp`, `udp`, IPv4, IPV6, etc.). If `n` parameter is not provided, it defaults to `tcp`. If `n` parameter is set to unknown network, an error will be returned.
* `t` - optional - timeout in seconds. If `t` parameter is not provided, it defaults to `10`. If `t` contains invalid integer literal, an error will be returned.
Check [Sample ping/reachability analyzer responses](#sample-pingreachability-analyzer-responses) to see how you can use yosoy for troubleshooting network connectivity.
## Docker image
The docker image is available on docker hub:
The docker image is available on docker hub and ghcr.io:
```sh
docker pull lukasz/yosoy
```
and ghcr.io:
```sh
docker pull ghcr.io/lukaszbudnik/yosoy
```
@@ -51,7 +60,7 @@ It exposes HTTP service on port 80.
## Kubernetes example
There is a sample Kubernetes deployment file in the `test` folder. It uses both `YOSOY_SHOW_ENVS` and `YOSOY_SHOW_FILES`. The deployment uses Kubernetes Downward API to expose labels and annotations as volume files which are then returned by yosoy.
There is a sample Kubernetes deployment file in the `test` folder. It uses both `YOSOY_SHOW_ENVS` and `YOSOY_SHOW_FILES` features. The deployment uses Kubernetes Downward API to expose labels and annotations as volume files which are then returned by yosoy.
Deploy it to minikube and execute curl to the service a couple of times:
@@ -131,3 +140,58 @@ A sample yosoy JSON response to a request made from a single page application (S
}
}
```
## Sample ping/reachability analyzer responses
To test if yosoy can connect to `google.com` on port `443` using default `tcp` network use the following command:
```bash
curl -v "http://localhost/_/yosoy/ping?h=google.com&p=443"
> GET /_/yosoy/ping?h=google.com&p=443 HTTP/1.1
> Host: localhost
> User-Agent: curl/7.86.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 17 Nov 2023 05:54:36 GMT
< Content-Length: 29
< Content-Type: text/plain; charset=utf-8
<
{"message":"ping succeeded"}
```
To see an unsuccessful response you may use localhost with some random port number:
```bash
curl -v "http://localhost/_/yosoy/ping?h=127.0.0.1&p=12345"
> GET /_/yosoy/ping?h=127.0.0.1&p=12345 HTTP/1.1
> Host: localhost
> User-Agent: curl/7.86.0
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
< Date: Fri, 17 Nov 2023 05:53:48 GMT
< Content-Length: 66
< Content-Type: text/plain; charset=utf-8
<
{"error":"dial tcp 127.0.0.1:12345: connect: connection refused"}
```
## Building and testing locally
Here are some commands to get you started.
Run yosoy directly on port 80.
```bash
go test -coverprofile cover.out
go tool cover -html=cover.out
go run server.go
```
Building local Docker container and run it on port 8080:
```bash
docker build -t yosoy-local:latest .
docker run --rm --name yosoy-local -p 8080:80 yosoy-local:latest
```

15
go.mod
View File

@@ -1,9 +1,16 @@
module github.com/lukaszbudnik/yosoy
go 1.16
go 1.21
require (
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/stretchr/testify v1.7.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1
github.com/stretchr/testify v1.8.4
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

26
go.sum
View File

@@ -1,16 +1,16 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -2,16 +2,21 @@ package main
import (
"encoding/json"
"io/ioutil"
"log"
"net"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
const PING_DEFAULT_TIMEOUT = 10
const PING_DEFAULT_NETWORK = "tcp"
type response struct {
Host string `json:"host"`
Proto string `json:"proto"`
@@ -27,6 +32,14 @@ type response struct {
Files map[string]string `json:"files,omitempty"`
}
type errorResponse struct {
Error string `json:"error"`
}
type successResponse struct {
Message string `json:"message"`
}
var counter = 0
var hostname = os.Getenv("HOSTNAME")
@@ -71,7 +84,7 @@ func handler(w http.ResponseWriter, req *http.Request) {
response.Files = make(map[string]string)
files := strings.Split(showFiles, ",")
for _, file := range files {
bytes, err := ioutil.ReadFile(file)
bytes, err := os.ReadFile(file)
if err != nil {
log.Printf("Could not read file %v: %v\n", file, err)
continue
@@ -86,6 +99,73 @@ func handler(w http.ResponseWriter, req *http.Request) {
json.NewEncoder(w).Encode(response)
}
func ping(w http.ResponseWriter, req *http.Request) {
// get h, p, n, t parameters from query string
hostname := req.URL.Query().Get("h")
port := req.URL.Query().Get("p")
network := req.URL.Query().Get("n")
timeoutString := req.URL.Query().Get("t")
var timeout int64 = PING_DEFAULT_TIMEOUT
// return HTTP BadRequest when hostname is empty
if hostname == "" {
w.WriteHeader(http.StatusBadRequest)
w.Header().Add("Content-Type", "application/json; charset=utf-8")
json.NewEncoder(w).Encode(&errorResponse{"hostname is empty"})
return
}
// return HTTP BadRequest when port is empty
if port == "" {
w.WriteHeader(http.StatusBadRequest)
w.Header().Add("Content-Type", "application/json; charset=utf-8")
json.NewEncoder(w).Encode(&errorResponse{"port is empty"})
return
}
// check if timeoutString is a valid int64, return HTTP BadRequest when invalid, otherwise set timeout value
if timeoutString != "" {
timeoutInt, err := strconv.ParseInt(timeoutString, 10, 64)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
w.Header().Add("Content-Type", "application/json; charset=utf-8")
json.NewEncoder(w).Encode(&errorResponse{"timeout is invalid"})
return
}
timeout = timeoutInt
}
// if network is empty set default to tcp
if network == "" {
network = PING_DEFAULT_NETWORK
}
// ping the hostname and port
err := pingHost(hostname, port, network, timeout)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Header().Add("Content-Type", "application/json; charset=utf-8")
json.NewEncoder(w).Encode(&errorResponse{err.Error()})
return
}
// return HTTP OK
w.WriteHeader(http.StatusOK)
w.Header().Add("Content-Type", "application/json; charset=utf-8")
json.NewEncoder(w).Encode(&successResponse{"ping succeeded"})
}
func pingHost(hostname, port, network string, timeout int64) error {
// create timeoutDuration variable of Duration type using timeout as the value in seconds
timeoutDuration := time.Duration(timeout) * time.Second
// open a socket to hostname and port
conn, err := net.DialTimeout(network, hostname+":"+port, timeoutDuration)
if err != nil {
return err
}
// close the socket
conn.Close()
return nil
}
func remoteAddrWithoutPort(req *http.Request) string {
remoteAddr := req.RemoteAddr
if index := strings.LastIndex(remoteAddr, ":"); index > 0 {
@@ -100,6 +180,7 @@ func main() {
r := mux.NewRouter()
r.Handle("/favicon.ico", r.NotFoundHandler)
r.HandleFunc("/_/yosoy/ping", ping).Methods(http.MethodGet)
r.PathPrefix("/").HandlerFunc(preflight).Methods(http.MethodOptions)
r.PathPrefix("/").HandlerFunc(handler).Methods(http.MethodGet, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete, http.MethodConnect, http.MethodHead, http.MethodTrace)
@@ -107,5 +188,5 @@ func main() {
proxyRouter := handlers.ProxyHeaders(loggingRouter)
recoveryRouter := handlers.RecoveryHandler()(proxyRouter)
http.ListenAndServe(":80", recoveryRouter)
http.ListenAndServe(":8080", recoveryRouter)
}

View File

@@ -1,7 +1,9 @@
package main
import (
"bytes"
"encoding/json"
"net"
"net/http"
"net/http/httptest"
"os"
@@ -12,7 +14,7 @@ import (
func TestHandler(t *testing.T) {
os.Setenv("YOSOY_SHOW_ENVS", "true")
os.Setenv("YOSOY_SHOW_FILES", ".gitignore")
os.Setenv("YOSOY_SHOW_FILES", ".gitignore,/file/does/not/exist")
req, err := http.NewRequest("GET", "https://example.org/sample/path?one=jeden&two=dwa", nil)
if err != nil {
@@ -29,8 +31,12 @@ func TestHandler(t *testing.T) {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
var response response
json.Unmarshal(rr.Body.Bytes(), &response)
json.Unmarshal(buf.Bytes(), &response)
// test response
assert.Equal(t, 1, response.Counter)
@@ -43,5 +49,257 @@ func TestHandler(t *testing.T) {
assert.NotEmpty(t, response.Files[".gitignore"])
// test cors
assert.Contains(t, rr.HeaderMap["Access-Control-Allow-Origin"], "*")
assert.Contains(t, result.Header["Access-Control-Allow-Origin"], "*")
}
// write test for request /_/yosoy/ping without any query parameters, the request should return bad request 400 error and return JSON error about missing hostname parameter
func TestHandlerPingNoParameters(t *testing.T) {
req, err := http.NewRequest("GET", "https://example.org/_/yosoy/ping", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Set("Accept", "*/*")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(ping)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusBadRequest {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusBadRequest)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
var response errorResponse
json.Unmarshal(buf.Bytes(), &response)
// test response
assert.Equal(t, "hostname is empty", response.Error)
}
// write test for request /_/yosoy/ping with h parameter, the request should return bad request 400 error and return JSON error about port is empty
func TestHandlerPingWithHostname(t *testing.T) {
req, err := http.NewRequest("GET", "https://example.org/_/yosoy/ping?h=example.org", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Set("Accept", "*/*")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(ping)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusBadRequest {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusBadRequest)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
var response errorResponse
json.Unmarshal(buf.Bytes(), &response)
// test response
assert.Equal(t, "port is empty", response.Error)
}
// write test for request /_/yosoy/ping with h=127.0.0.1 parameter and p=8123 parameter, the request should return bad request 400 error and return JSON error about tcp connection issue
func TestHandlerPingWithHostnameAndPort(t *testing.T) {
req, err := http.NewRequest("GET", "https://example.org/_/yosoy/ping?h=127.0.0.1&p=8123", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Set("Accept", "*/*")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(ping)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusInternalServerError {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusInternalServerError)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
var response errorResponse
json.Unmarshal(buf.Bytes(), &response)
// test response
assert.Equal(t, "dial tcp 127.0.0.1:8123: connect: connection refused", response.Error)
}
// write test for request /_/yosoy/ping with h=127.0.0.1 parameter and p=8123 parameter, the request should return 200 ok and return JSON with message ping succeeded
func TestHandlerPingWithHostnameAndPortSuccess(t *testing.T) {
// create tcp process to listen on port 8123
listener, err := net.Listen("tcp", "localhost:8123")
if err != nil {
t.Fatal(err)
}
defer listener.Close()
req, err := http.NewRequest("GET", "https://example.org/_/yosoy/ping?h=127.0.0.1&p=8123", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Set("Accept", "*/*")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(ping)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
var response successResponse
json.Unmarshal(buf.Bytes(), &response)
// test response
assert.Equal(t, "ping succeeded", response.Message)
}
// write test for request /_/yosoy/ping?h=127.0.0.1&p=8123&n=qwq, the request should return 500 internal server error and return JSON with error "dial qwq: unknown network qwq"
func TestHandlerPingWithHostnameAndPortAndNetwork(t *testing.T) {
// create tcp process to listen on port 8123
listener, err := net.Listen("tcp", "localhost:8123")
if err != nil {
t.Fatal(err)
}
defer listener.Close()
req, err := http.NewRequest("GET", "https://example.org/_/yosoy/ping?h=127.0.0.1&p=8123&n=qwq", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Set("Accept", "*/*")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(ping)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusInternalServerError {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusInternalServerError)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
var response errorResponse
json.Unmarshal(buf.Bytes(), &response)
// test response
assert.Equal(t, "dial qwq: unknown network qwq", response.Error)
}
// write test for preflight HTTP Options request, verify that all headers are set
func TestHandlerPreflight(t *testing.T) {
req, err := http.NewRequest("OPTIONS", "https://example.org/test", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Set("Accept", "*/*")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(preflight)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
// test response
assert.Equal(t, "*", result.Header.Get("Access-Control-Allow-Origin"))
assert.Equal(t, "*", result.Header.Get("Access-Control-Allow-Methods"))
assert.Equal(t, "*", result.Header.Get("Access-Control-Allow-Headers"))
assert.Equal(t, "true", result.Header.Get("Access-Control-Allow-Credentials"))
assert.Equal(t, "600", result.Header.Get("Access-Control-Max-Age"))
assert.Equal(t, "*", result.Header.Get("Access-Control-Expose-Headers"))
}
// write test for request /_/yosoy/ping?h=127.0.0.1&p=8123&n=tcp&t=5, the request should return 200 ok and return JSON with message "ping succeeded"
func TestHandlerPingWithHostnameAndPortAndNetworkAndTimeout(t *testing.T) {
// create tcp process to listen on port 8123
listener, err := net.Listen("tcp", "localhost:8123")
if err != nil {
t.Fatal(err)
}
defer listener.Close()
req, err := http.NewRequest("GET", "https://example.org/_/yosoy/ping?h=127.0.0.1&p=8123&n=tcp&t=5", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Set("Accept", "*/*")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(ping)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
var response successResponse
json.Unmarshal(buf.Bytes(), &response)
// test response
assert.Equal(t, "ping succeeded", response.Message)
}
// write test for request /_/yosoy/ping?h=127.0.0.1&p=8123&n=tcp&t=invalid, the request should return 400 bad request and return JSON with error "timeout is invalid"
func TestHandlerPingWithHostnameAndPortAndNetworkAndTimeoutInvalid(t *testing.T) {
// create tcp process to listen on port 8123
listener, err := net.Listen("tcp", "localhost:8123")
if err != nil {
t.Fatal(err)
}
defer listener.Close()
req, err := http.NewRequest("GET", "https://example.org/_/yosoy/ping?h=127.0.0.1&p=8123&n=tcp&t=invalid", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Set("Accept", "*/*")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(ping)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusBadRequest {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusBadRequest)
}
result := rr.Result()
buf := new(bytes.Buffer)
buf.ReadFrom(result.Body)
var response errorResponse
json.Unmarshal(buf.Bytes(), &response)
// test response
assert.Equal(t, "timeout is invalid", response.Error)
}

View File

@@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: yosoy
image: lukasz/yosoy:2.0.3
image: lukasz/yosoy:edge
env:
- name: YOSOY_SHOW_ENVS
value: "true"