From 2926acbf6bef1d7fb31f27aa71dd3568933744b4 Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Thu, 15 Aug 2024 14:31:15 -0500 Subject: [PATCH 1/8] go test workflow --- .github/workflows/tests.yml | 18 ++++ pkg/wireguard/wireguardclientconfig_test.go | 103 ++++++++++++++++---- 2 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b423762 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,18 @@ +name: Go test + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + steps: + - name: Setup Go 1.21.x + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + - name: Install dependencies + run: | + go get . + - name: Test + run: make test diff --git a/pkg/wireguard/wireguardclientconfig_test.go b/pkg/wireguard/wireguardclientconfig_test.go index c7074db..3e2c159 100644 --- a/pkg/wireguard/wireguardclientconfig_test.go +++ b/pkg/wireguard/wireguardclientconfig_test.go @@ -10,6 +10,7 @@ import ( "net/netip" "strings" "testing" + "time" testingmocks "github.com/in4it/wireguard-server/pkg/testing/mocks" ) @@ -52,9 +53,20 @@ func TestGetConfigNumberFromConnectionFile(t *testing.T) { } func TestWriteConfig(t *testing.T) { - l, err := net.Listen("tcp", CONFIGMANAGER_URI) - if err != nil { - t.Fatal(err) + var ( + l net.Listener + err error + ) + for { + l, err = net.Listen("tcp", CONFIGMANAGER_URI) + if err != nil { + if !strings.HasSuffix(err.Error(), "address already in use") { + t.Fatal(err) + } + time.Sleep(1 * time.Second) + } else { + break + } } ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -113,9 +125,20 @@ func TestWriteConfig(t *testing.T) { } func TestWriteConfigMultipleClients(t *testing.T) { - l, err := net.Listen("tcp", CONFIGMANAGER_URI) - if err != nil { - t.Fatal(err) + var ( + l net.Listener + err error + ) + for { + l, err = net.Listen("tcp", CONFIGMANAGER_URI) + if err != nil { + if !strings.HasSuffix(err.Error(), "address already in use") { + t.Fatal(err) + } + time.Sleep(1 * time.Second) + } else { + break + } } ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -176,9 +199,20 @@ func TestWriteConfigMultipleClients(t *testing.T) { } func TestCreateAndDeleteAllClientConfig(t *testing.T) { - l, err := net.Listen("tcp", CONFIGMANAGER_URI) - if err != nil { - t.Fatal(err) + var ( + l net.Listener + err error + ) + for { + l, err = net.Listen("tcp", CONFIGMANAGER_URI) + if err != nil { + if !strings.HasSuffix(err.Error(), "address already in use") { + t.Fatal(err) + } + time.Sleep(1 * time.Second) + } else { + break + } } ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -253,9 +287,20 @@ func TestCreateAndDeleteAllClientConfig(t *testing.T) { } } func TestCreateAndDeleteClientConfig(t *testing.T) { - l, err := net.Listen("tcp", CONFIGMANAGER_URI) - if err != nil { - t.Fatal(err) + var ( + l net.Listener + err error + ) + for { + l, err = net.Listen("tcp", CONFIGMANAGER_URI) + if err != nil { + if !strings.HasSuffix(err.Error(), "address already in use") { + t.Fatal(err) + } + time.Sleep(1 * time.Second) + } else { + break + } } ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -331,9 +376,20 @@ func TestCreateAndDeleteClientConfig(t *testing.T) { } func TestCreateAndDisableAllClientConfig(t *testing.T) { - l, err := net.Listen("tcp", CONFIGMANAGER_URI) - if err != nil { - t.Fatal(err) + var ( + l net.Listener + err error + ) + for { + l, err = net.Listen("tcp", CONFIGMANAGER_URI) + if err != nil { + if !strings.HasSuffix(err.Error(), "address already in use") { + t.Fatal(err) + } + time.Sleep(1 * time.Second) + } else { + break + } } ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -444,9 +500,20 @@ func TestCreateAndDisableAllClientConfig(t *testing.T) { } func TestUpdateClientConfig(t *testing.T) { - l, err := net.Listen("tcp", CONFIGMANAGER_URI) - if err != nil { - t.Fatal(err) + var ( + l net.Listener + err error + ) + for { + l, err = net.Listen("tcp", CONFIGMANAGER_URI) + if err != nil { + if !strings.HasSuffix(err.Error(), "address already in use") { + t.Fatal(err) + } + time.Sleep(1 * time.Second) + } else { + break + } } ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { From 6f4e341907e3049140c403b29b990555383d0165 Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Thu, 15 Aug 2024 14:33:01 -0500 Subject: [PATCH 2/8] checkout repo in github worfklow --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b423762..3116129 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,6 +7,7 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Setup Go 1.21.x uses: actions/setup-go@v5 with: From 731b8a15bf40339b2dc525bfc4aa89f9c8d082df Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Thu, 15 Aug 2024 14:34:03 -0500 Subject: [PATCH 3/8] go get in subdirs in github worfklow --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3116129..b0b3fd5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,6 +14,6 @@ jobs: go-version: '1.21.x' - name: Install dependencies run: | - go get . + go get ./... - name: Test run: make test From 025e1128303d4693e383f82f226adb9c006dc90d Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Thu, 15 Aug 2024 14:35:42 -0500 Subject: [PATCH 4/8] go generate in github worfklow --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b0b3fd5..8f7b2ca 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,5 +15,8 @@ jobs: - name: Install dependencies run: | go get ./... + - name: Go generate + run: | + go generate ./... - name: Test run: make test From 51865ab26265475cd3ac68856dd532c8da96646a Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Thu, 15 Aug 2024 14:38:43 -0500 Subject: [PATCH 5/8] add resources directories --- pkg/configmanager/resources/.gitignore | 4 ++++ pkg/rest/resources/.gitignore | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 pkg/configmanager/resources/.gitignore create mode 100644 pkg/rest/resources/.gitignore diff --git a/pkg/configmanager/resources/.gitignore b/pkg/configmanager/resources/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/pkg/configmanager/resources/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/pkg/rest/resources/.gitignore b/pkg/rest/resources/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/pkg/rest/resources/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore From 5226c26fbb1735a15f053d60e71dc1fb307f2a6b Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Thu, 15 Aug 2024 14:42:06 -0500 Subject: [PATCH 6/8] static directory --- pkg/rest/static/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 pkg/rest/static/.gitignore diff --git a/pkg/rest/static/.gitignore b/pkg/rest/static/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/pkg/rest/static/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore From c5ff0854c9da215e66916c4e108ae1d5a1e7bb9d Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Thu, 15 Aug 2024 14:48:12 -0500 Subject: [PATCH 7/8] placeholder file --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8f7b2ca..6cadf56 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,5 +18,6 @@ jobs: - name: Go generate run: | go generate ./... + touch pkg/rest/static/placeholder # we're not building frontend, so we put a placeholder - name: Test run: make test From 6c983731d875eddb8280022995bc7fdaa8bc3710 Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Thu, 15 Aug 2024 15:21:38 -0500 Subject: [PATCH 8/8] axios dependency bump --- webapp/package-lock.json | 9 +++++---- webapp/package.json | 2 +- webapp/yarn.lock | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 4419645..842d3eb 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -13,7 +13,7 @@ "@mantine/hooks": "^7.9.2", "@tabler/icons-react": "^3.4.0", "@tanstack/react-query": "^5.36.2", - "axios": "^1.6.8", + "axios": "^1.7.4", "base32-encode": "^2.0.0", "react": "^18.2.0", "react-cookie": "^7.1.4", @@ -1838,9 +1838,10 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", - "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", + "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", diff --git a/webapp/package.json b/webapp/package.json index 1bfb2e3..44a2ab6 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -16,7 +16,7 @@ "@mantine/hooks": "^7.9.2", "@tabler/icons-react": "^3.4.0", "@tanstack/react-query": "^5.36.2", - "axios": "^1.6.8", + "axios": "^1.7.4", "base32-encode": "^2.0.0", "react": "^18.2.0", "react-cookie": "^7.1.4", diff --git a/webapp/yarn.lock b/webapp/yarn.lock index 26f8b2c..386f00a 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -701,10 +701,10 @@ asynckit@^0.4.0: resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -axios@^1.6.8: - version "1.7.2" - resolved "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz" - integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw== +axios@^1.7.4: + version "1.7.4" + resolved "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz" + integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw== dependencies: follow-redirects "^1.15.6" form-data "^4.0.0"