Skyler Grey | d7e1acd | 2024-06-22 14:42:11 +0000 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2024 Clicks Codes |
| 2 | # |
| 3 | # SPDX-License-Identifier: GPL-3.0-only |
| 4 | |
| 5 | { lib, ... }: let |
| 6 | tailscaleAuthWithRoute = { |
| 7 | "calibre.clicks.codes" = { |
| 8 | routes."/somePath" = lib.home-manager.hm.dag.entryAnywhere { |
| 9 | host = "generic"; |
| 10 | port = 1024; |
| 11 | _type = "reverseProxy"; |
| 12 | headers = null; |
| 13 | }; |
| 14 | dnsProvider = "cloudflare"; |
| 15 | service = null; |
| 16 | authWith = "tailscale"; |
| 17 | enableHttp = false; |
| 18 | }; |
| 19 | }; |
| 20 | serviceAndRoutes = { |
| 21 | "calibre.clicks.codes" = { |
| 22 | routes."/somePath" = lib.home-manager.hm.dag.entryAnywhere { |
| 23 | host = "generic"; |
| 24 | port = 1024; |
| 25 | _type = "reverseProxy"; |
| 26 | headers = null; |
| 27 | }; |
| 28 | dnsProvider = "cloudflare"; |
| 29 | service = { |
| 30 | host = "generic"; |
| 31 | port = 1024; |
| 32 | _type = "reverseProxy"; |
| 33 | headers = null; |
| 34 | }; |
| 35 | authWith = "tailscale"; |
| 36 | enableHttp = false; |
| 37 | }; |
| 38 | }; |
| 39 | neitherServiceOrRoutes = { |
| 40 | "calibre.clicks.codes" = { |
| 41 | routes = null; |
| 42 | dnsProvider = "cloudflare"; |
| 43 | service = null; |
| 44 | authWith = "tailscale"; |
| 45 | enableHttp = false; |
| 46 | }; |
| 47 | }; |
| 48 | in { |
| 49 | testAssertTailscaleAuthServiceOnlyFail = { |
| 50 | /* This is NOT considered a step, here we test that it passes through input */ |
| 51 | expr = lib.clicks.nginx.http.internal.assertTailscaleAuthServiceOnly tailscaleAuthWithRoute; |
| 52 | expectedError = { |
| 53 | type = "ThrownError"; |
| 54 | msg = "calibre.clicks.codes: You may not use tailscale auth when manually specifying `routes`. Please use `service` instead"; |
| 55 | }; |
| 56 | }; |
| 57 | testAssertExactlyOneOServiceOrRoutesBothProvidedFail = { |
| 58 | expr = lib.clicks.nginx.http.internal.assertExactlyOneOfServiceOrRoutes serviceAndRoutes; |
| 59 | expectedError = { |
| 60 | type = "ThrownError"; |
| 61 | msg = "calibre.clicks.codes: You may only provide one of `service` or `routes`"; |
| 62 | }; |
| 63 | }; |
| 64 | testAssertExactlyOneOfServiceOrRoutesNeitherProvidedFail = { |
| 65 | expr = lib.clicks.nginx.http.internal.assertExactlyOneOfServiceOrRoutes neitherServiceOrRoutes; |
| 66 | expectedError = { |
| 67 | type = "ThrownError"; |
| 68 | msg = "calibre.clicks.codes: You must provide one of `service` or `routes`"; |
| 69 | }; |
| 70 | }; |
| 71 | } |