From 397d4a9f516b73fa8a49aea0f6f6688cd0bbaa19 Mon Sep 17 00:00:00 2001 From: Caleb Doxsey Date: Fri, 15 May 2020 09:25:27 -0600 Subject: [PATCH] integration-tests: switch to go for backends to support TLS scenarios (#707) * integration-tests: switch to go for backends to support TLS scenarios * fix apply order * fix duplicate port value --- go.mod | 3 - go.sum | 23 +---- integration/backends/httpdetails/go.mod | 3 + integration/backends/httpdetails/index.js | 29 ------- integration/backends/httpdetails/main.go | 69 +++++++++++++++ integration/backends/ws-echo/go.mod | 5 ++ integration/backends/ws-echo/go.sum | 2 + integration/backends/ws-echo/index.js | 10 --- integration/backends/ws-echo/main.go | 60 +++++++++++++ integration/backends/ws-echo/package.json | 14 ---- integration/internal/cluster/setup.go | 2 +- integration/manifests/lib/backends.libsonnet | 88 +++++++++++--------- integration/policy_test.go | 14 ++-- 13 files changed, 198 insertions(+), 124 deletions(-) create mode 100644 integration/backends/httpdetails/go.mod delete mode 100644 integration/backends/httpdetails/index.js create mode 100644 integration/backends/httpdetails/main.go create mode 100644 integration/backends/ws-echo/go.mod create mode 100644 integration/backends/ws-echo/go.sum delete mode 100644 integration/backends/ws-echo/index.js create mode 100644 integration/backends/ws-echo/main.go delete mode 100644 integration/backends/ws-echo/package.json diff --git a/go.mod b/go.mod index 80ee798bd..c486b2d41 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,6 @@ require ( github.com/onsi/gomega v1.8.1 // indirect github.com/open-policy-agent/opa v0.19.2 github.com/pelletier/go-toml v1.6.0 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pomerium/autocache v0.0.0-20200505053831-8c1cd659f055 github.com/pomerium/csrf v1.6.2-0.20190918035251-f3318380bad3 github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect @@ -47,9 +46,7 @@ require ( golang.org/x/net v0.0.0-20200506145744-7e3656a0809f golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d google.golang.org/api v0.23.0 - google.golang.org/appengine v1.6.5 // indirect google.golang.org/grpc v1.28.0 - gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/square/go-jose.v2 v2.5.1 gopkg.in/yaml.v2 v2.2.8 ) diff --git a/go.sum b/go.sum index a1782f03f..1a5cea827 100644 --- a/go.sum +++ b/go.sum @@ -67,7 +67,6 @@ github.com/aliyun/alibaba-cloud-sdk-go v1.61.112/go.mod h1:pUKYbK5JQ+1Dfxk80P0qx github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.0 h1:B7AQgHi8QSEi4uHu7Sbsga+IJDU+CENgjxoo81vDUqU= github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs= @@ -104,7 +103,6 @@ github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkE github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-oidc v2.2.1+incompatible h1:mh48q/BqXqgjVHpy2ZY7WnWAbenxRjsz9N1i1YxjHAk= github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -239,8 +237,7 @@ github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -270,6 +267,7 @@ github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjG github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -283,8 +281,6 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.2.0 h1:WeeNspppWi5s1OFefTviPQueC/Bq8dONfvNjPhiEQKE= -github.com/hashicorp/memberlist v0.2.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/memberlist v0.2.2 h1:5+RffWKwqJ71YPu9mWsF7ZOscZmwfasdA8kbdC7AO2g= github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= @@ -408,8 +404,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/pomerium/autocache v0.0.0-20200309220911-227c9939d0ce h1:oqn4rqjp23rLyW3wwsYnWf01iNgeKsE29N6EMycTvlA= -github.com/pomerium/autocache v0.0.0-20200309220911-227c9939d0ce/go.mod h1:C6qF5bWZF7gIkJurnnWKx/PgJjYfR9aSfpOzpM454fo= github.com/pomerium/autocache v0.0.0-20200505053831-8c1cd659f055 h1:y73x4eEnZkCHdC46HG2h+ZAuNQUW1tu7hgvC7v+jI2o= github.com/pomerium/autocache v0.0.0-20200505053831-8c1cd659f055/go.mod h1:xCwNSx2PcCbOG6XT0PpAGRkM5ZHnbXZLKg2ntE22j+M= github.com/pomerium/csrf v1.6.2-0.20190918035251-f3318380bad3 h1:FmzFXnCAepHZwl6QPhTFqBHcbcGevdiEQjutK+M5bj4= @@ -511,8 +505,6 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.6.3 h1:pDDu1OyEDTKzpJwdq4TiuLyMsUgRa/BT5cn5O62NoHs= -github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -542,7 +534,6 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b h1:vVRagRXf67ESqAb72hG2C/ZwI8NtJF2u2V76EsuOHGY= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b/go.mod h1:HptNXiXVDcJjXe9SqMd0v2FsL9f8dz4GnXgltU6q/co= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -577,8 +568,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200117160349-530e935923ad h1:Jh8cai0fqIK+f6nG0UgPW5wFk8wmiMhM3AyciDBdtQg= golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 h1:IaQbIIB2X/Mp/DKctl6ROxz1KyMlKp4uyvL6+kQ7C88= -golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -627,7 +616,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -644,8 +632,6 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M= -golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f h1:QBjCr1Fz5kw158VqdE9JfI9cJnl/ymnJWAdMuinqL7Y= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -779,8 +765,6 @@ google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsb google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0 h1:J1Pl9P2lnmYFSJvgs70DKELqHNh8CNWXPbud4njEE2s= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.23.0 h1:YlvGEOq2NA2my8cZ/9V8BcEO9okD48FlJcdqN0xJL3s= google.golang.org/api v0.23.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -806,8 +790,6 @@ google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200204235621-fb4a7afc5178 h1:4mrurAiSXsNNb6GoJatrIsnI+JqKHAVQQ1SbMS5OtDI= -google.golang.org/genproto v0.0.0-20200204235621-fb4a7afc5178/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171 h1:xes2Q2k+d/+YNXVw0FpZkIDJiaux4OVrRKXRAzH6A0U= @@ -818,7 +800,6 @@ google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/integration/backends/httpdetails/go.mod b/integration/backends/httpdetails/go.mod new file mode 100644 index 000000000..b0ad06f39 --- /dev/null +++ b/integration/backends/httpdetails/go.mod @@ -0,0 +1,3 @@ +module github.com/pomerium/pomerium/integration/backends/httpdetails + +go 1.14 diff --git a/integration/backends/httpdetails/index.js b/integration/backends/httpdetails/index.js deleted file mode 100644 index 04612f15a..000000000 --- a/integration/backends/httpdetails/index.js +++ /dev/null @@ -1,29 +0,0 @@ -const http = require("http"); - -const requestListener = function (req, res) { - const { - pathname: path, - hostname: host, - port: port, - search: query, - hash: hash, - } = new URL(req.url, `http://${req.headers.host}`); - - res.setHeader("Content-Type", "application/json"); - res.writeHead(200); - res.end( - JSON.stringify({ - headers: req.headers, - method: req.method, - host: host, - port: port, - path: path, - query: query, - hash: hash, - }) - ); -}; - -const server = http.createServer(requestListener); -console.log("starting http server on :8080"); -server.listen(8080); diff --git a/integration/backends/httpdetails/main.go b/integration/backends/httpdetails/main.go new file mode 100644 index 000000000..fe98808e9 --- /dev/null +++ b/integration/backends/httpdetails/main.go @@ -0,0 +1,69 @@ +package main + +import ( + "encoding/json" + "flag" + "fmt" + "net/http" + "os" +) + +func main() { + var ( + certFile, keyFile, bindAddr string + ) + + flag.StringVar(&certFile, "cert-file", "", "the tls cert file to use") + flag.StringVar(&keyFile, "key-file", "", "the tls key file to use") + flag.StringVar(&bindAddr, "bind-addr", "", "the address to listen on") + flag.Parse() + + var err error + if certFile != "" && keyFile != "" { + if bindAddr == "" { + bindAddr = ":5443" + } + fmt.Println("starting server on", bindAddr) + err = http.ListenAndServeTLS(bindAddr, certFile, keyFile, http.HandlerFunc(handle)) + } else { + if bindAddr == "" { + bindAddr = ":5080" + } + fmt.Println("starting server on", bindAddr) + err = http.ListenAndServe(bindAddr, http.HandlerFunc(handle)) + } + if err != nil { + fmt.Fprintf(os.Stderr, "failed to listen and serve: %v", err) + os.Exit(1) + } +} + +type Result struct { + Headers map[string]string `json:"headers"` + Method string `json:"method"` + Host string `json:"host"` + Port string `json:"port"` + Path string `json:"path"` + Query string `json:"query"` + RequestURI string `json:"requestURI"` +} + +func handle(w http.ResponseWriter, r *http.Request) { + res := &Result{ + Headers: map[string]string{}, + Method: r.Method, + Host: r.Host, + Port: r.URL.Port(), + Path: r.URL.Path, + Query: r.URL.RawQuery, + RequestURI: r.RequestURI, + } + for k := range r.Header { + res.Headers[k] = r.Header.Get(k) + } + res.Headers["Host"] = r.Host + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + _ = json.NewEncoder(w).Encode(res) +} diff --git a/integration/backends/ws-echo/go.mod b/integration/backends/ws-echo/go.mod new file mode 100644 index 000000000..e4f509383 --- /dev/null +++ b/integration/backends/ws-echo/go.mod @@ -0,0 +1,5 @@ +module github.com/pomerium/pomerium/integration/backends/ws-echo + +go 1.14 + +require github.com/gorilla/websocket v1.4.2 diff --git a/integration/backends/ws-echo/go.sum b/integration/backends/ws-echo/go.sum new file mode 100644 index 000000000..85efffd99 --- /dev/null +++ b/integration/backends/ws-echo/go.sum @@ -0,0 +1,2 @@ +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= diff --git a/integration/backends/ws-echo/index.js b/integration/backends/ws-echo/index.js deleted file mode 100644 index c41f8e7ec..000000000 --- a/integration/backends/ws-echo/index.js +++ /dev/null @@ -1,10 +0,0 @@ -const WebSocket = require("ws"); - -console.log("starting websocket server on :8080"); -const wss = new WebSocket.Server({ port: 8080 }); -wss.on("connection", function connection(ws) { - ws.on("message", function incoming(message) { - console.log("received: %s", message); - ws.send(message); - }); -}); diff --git a/integration/backends/ws-echo/main.go b/integration/backends/ws-echo/main.go new file mode 100644 index 000000000..b42f6505d --- /dev/null +++ b/integration/backends/ws-echo/main.go @@ -0,0 +1,60 @@ +package main + +import ( + "flag" + "fmt" + "net/http" + "os" + + "github.com/gorilla/websocket" +) + +func main() { + var ( + certFile, keyFile, bindAddr string + ) + + flag.StringVar(&certFile, "cert-file", "", "the tls cert file to use") + flag.StringVar(&keyFile, "key-file", "", "the tls key file to use") + flag.StringVar(&bindAddr, "bind-addr", "", "the address to listen on") + flag.Parse() + + var err error + if certFile != "" && keyFile != "" { + if bindAddr == "" { + bindAddr = ":5443" + } + fmt.Println("starting server on", bindAddr) + err = http.ListenAndServeTLS(bindAddr, certFile, keyFile, http.HandlerFunc(handle)) + } else { + if bindAddr == "" { + bindAddr = ":5080" + } + fmt.Println("starting server on", bindAddr) + err = http.ListenAndServe(bindAddr, http.HandlerFunc(handle)) + } + if err != nil { + fmt.Fprintf(os.Stderr, "failed to listen and serve: %v", err) + os.Exit(1) + } +} + +func handle(w http.ResponseWriter, r *http.Request) { + conn, err := websocket.Upgrade(w, r, nil, 1024, 1024) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + defer conn.Close() + + for { + mt, p, err := conn.ReadMessage() + if err != nil { + return + } + + err = conn.WriteMessage(mt, p) + if err != nil { + return + } + } +} diff --git a/integration/backends/ws-echo/package.json b/integration/backends/ws-echo/package.json deleted file mode 100644 index 64979df60..000000000 --- a/integration/backends/ws-echo/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "ws-echo", - "version": "0.1.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "ws": "^7.2.5" - } -} diff --git a/integration/internal/cluster/setup.go b/integration/internal/cluster/setup.go index dcf1e3dc0..4cbd7e26f 100644 --- a/integration/internal/cluster/setup.go +++ b/integration/internal/cluster/setup.go @@ -21,12 +21,12 @@ import ( ) var requiredDeployments = []string{ + "ingress-nginx/nginx-ingress-controller", "default/httpdetails", "default/openid", "default/pomerium-authenticate", "default/pomerium-authorize", "default/pomerium-proxy", - "ingress-nginx/nginx-ingress-controller", } // Setup configures the test cluster so that it is ready for the integration tests. diff --git a/integration/manifests/lib/backends.libsonnet b/integration/manifests/lib/backends.libsonnet index 7f729eed7..d2e1f064d 100644 --- a/integration/manifests/lib/backends.libsonnet +++ b/integration/manifests/lib/backends.libsonnet @@ -21,11 +21,18 @@ local service = function(name) { }, spec: { selector: { app: name }, - ports: [{ - name: 'http', - port: 80, - targetPort: 'http', - }], + ports: [ + { + name: 'http', + port: 80, + targetPort: 'http', + }, + { + name: 'https', + port: 443, + targetPort: 'https', + }, + ], }, }; @@ -44,42 +51,43 @@ local deployment = function(name) { labels: { app: name }, }, spec: { - initContainers: [{ - name: 'init', - image: 'node:14-stretch-slim', - imagePullPolicy: 'IfNotPresent', - args: ['bash', '-c', 'cp -rL /src/* /app/'], - volumeMounts: [{ - name: 'src', - mountPath: '/src', - }, { - name: 'app', - mountPath: '/app', - }], - }], containers: [{ name: name, - image: 'node:14-stretch-slim', + image: 'golang:buster', imagePullPolicy: 'IfNotPresent', - args: ['bash', '-c', 'cd /app && npm install && node index.js'], - ports: [{ - name: 'http', - containerPort: 8080, - }], - volumeMounts: [{ - name: 'app', - mountPath: '/app', - }], + args: [ + 'bash', + '-c', + ||| + cd /src + go run . + |||, + ], + ports: [ + { + name: 'http', + containerPort: 5080, + }, + { + name: 'https', + containerPort: 5443, + }, + ], + volumeMounts: [ + { + name: 'src', + mountPath: '/src', + }, + ], }], - volumes: [{ - name: 'src', - configMap: { - name: name, + volumes: [ + { + name: 'src', + configMap: { + name: name, + }, }, - }, { - name: 'app', - emptyDir: {}, - }], + ], }, }, }, @@ -90,14 +98,16 @@ local deployment = function(name) { kind: 'List', items: [ configMap('httpdetails', { - 'index.js': importstr '../../backends/httpdetails/index.js', + 'main.go': importstr '../../backends/httpdetails/main.go', + 'go.mod': importstr '../../backends/httpdetails/go.mod', }), service('httpdetails'), deployment('httpdetails'), configMap('ws-echo', { - 'package.json': importstr '../../backends/ws-echo/package.json', - 'index.js': importstr '../../backends/ws-echo/index.js', + 'main.go': importstr '../../backends/ws-echo/main.go', + 'go.mod': importstr '../../backends/ws-echo/go.mod', + 'go.sum': importstr '../../backends/ws-echo/go.sum', }), service('ws-echo'), deployment('ws-echo'), diff --git a/integration/policy_test.go b/integration/policy_test.go index 49412a490..72b527de7 100644 --- a/integration/policy_test.go +++ b/integration/policy_test.go @@ -75,15 +75,15 @@ func TestPreserveHostHeader(t *testing.T) { defer res.Body.Close() var result struct { - Headers map[string]string `json:"headers"` + Host string `json:"host"` } err = json.NewDecoder(res.Body).Decode(&result) if !assert.NoError(t, err) { return } - assert.Equal(t, "httpdetails.localhost.pomerium.io", result.Headers["host"], - "destination host should be preserved") + assert.Equal(t, "httpdetails.localhost.pomerium.io", result.Host, + "destination host should be preserved in %v", result) }) t.Run("disabled", func(t *testing.T) { client := testcluster.NewHTTPClient() @@ -100,15 +100,15 @@ func TestPreserveHostHeader(t *testing.T) { defer res.Body.Close() var result struct { - Headers map[string]string `json:"headers"` + Host string `json:"host"` } err = json.NewDecoder(res.Body).Decode(&result) if !assert.NoError(t, err) { return } - assert.NotEqual(t, "httpdetails.localhost.pomerium.io", result.Headers["host"], - "destination host should not be preserved") + assert.NotEqual(t, "httpdetails.localhost.pomerium.io", result.Host, + "destination host should not be preserved in %v", result) }) } @@ -139,7 +139,7 @@ func TestSetRequestHeaders(t *testing.T) { return } - assert.Equal(t, "custom-request-header-value", result.Headers["x-custom-request-header"], + assert.Equal(t, "custom-request-header-value", result.Headers["X-Custom-Request-Header"], "expected custom request header to be sent upstream") }