From 48b5f301364b48747c7c854d232e942255bc2784 Mon Sep 17 00:00:00 2001 From: oeeve Date: Mon, 5 Jan 2026 00:28:10 +0100 Subject: [PATCH 1/6] changes to Readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b7..8e9ae5414db 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,5 @@ go build -o notely && ./notely *This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! + +NN's version of Boot.dev's Notely app. From 883959bbe32fc289211d885ced4d2f42d6868a36 Mon Sep 17 00:00:00 2001 From: oeeve Date: Wed, 14 Jan 2026 13:53:03 +0000 Subject: [PATCH 2/6] updates --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..249cc5258a3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: ci + +on: + pull_request: + branches: [main] + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.25.1" + + - name: Force Failure + run: (exit 1) From aa02ba675a347d67773d4141d289a4392950dce4 Mon Sep 17 00:00:00 2001 From: oeeve Date: Wed, 14 Jan 2026 14:16:18 +0000 Subject: [PATCH 3/6] updates to workflow --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 249cc5258a3..761ce5e7428 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,7 @@ jobs: with: go-version: "1.25.1" - - name: Force Failure - run: (exit 1) + - name: Print Version + run: | + go version + exit 0 From 73745faed2df09db30e0c6e93453c5e5be227123 Mon Sep 17 00:00:00 2001 From: oeeve Date: Wed, 14 Jan 2026 14:24:48 +0000 Subject: [PATCH 4/6] Updated CI to run go version and exit cleanly --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 249cc5258a3..0bc1f972eb5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,7 @@ jobs: with: go-version: "1.25.1" - - name: Force Failure - run: (exit 1) + - name: print go version + run: | + go version + exit 0 From f2607185e12f4d356dc65cb22ca5b17a82d2cc89 Mon Sep 17 00:00:00 2001 From: oeeve Date: Fri, 16 Jan 2026 06:48:17 +0000 Subject: [PATCH 5/6] created test for the GetAPI function --- .github/workflows/ci.yml | 2 +- internal/auth/auth_test.go | 77 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 internal/auth/auth_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bc1f972eb5..c00c108ca26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,5 +20,5 @@ jobs: - name: print go version run: | - go version + go test ./... exit 0 diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 00000000000..2ea638d00d3 --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,77 @@ +package auth + +import ( + "errors" + "net/http" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + tests := []struct { + name string + headers http.Header + expectedKey string + expectedError error + }{ + { + name: "valid API key with correct format", + headers: http.Header{ + "Authorization": []string{"ApiKey my-secret-api-key-12345"}, + }, + expectedKey: "my-secret-api-key-12345", + expectedError: nil, + }, + { + name: "missing Authorization header", + headers: http.Header{}, + expectedKey: "", + expectedError: ErrNoAuthHeaderIncluded, + }, + { + name: "malformed Authorization header - wrong scheme", + headers: http.Header{ + "Authorization": []string{"Bearer my-token"}, + }, + expectedKey: "", + expectedError: errors.New("malformed authorization header"), + }, + { + name: "malformed Authorization header - only ApiKey without value", + headers: http.Header{ + "Authorization": []string{"ApiKey"}, + }, + expectedKey: "", + expectedError: errors.New("malformed authorization header"), + }, + { + name: "empty Authorization header value", + headers: http.Header{ + "Authorization": []string{""}, + }, + expectedKey: "", + expectedError: ErrNoAuthHeaderIncluded, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + apiKey, err := GetAPIKey(tt.headers) + + // Check the API key + if apiKey != tt.expectedKey { + t.Errorf("GetAPIKey() apiKey = %v, want %v", apiKey, tt.expectedKey) + } + + // Check the error + if tt.expectedError != nil && err == nil { + t.Errorf("GetAPIKey() error = nil, want %v", tt.expectedError) + } + if tt.expectedError == nil && err != nil { + t.Errorf("GetAPIKey() error = %v, want nil", err) + } + if tt.expectedError != nil && err != nil && err.Error() != tt.expectedError.Error() { + t.Errorf("GetAPIKey() error = %v, want %v", err, tt.expectedError) + } + }) + } +} From 18290060183bab3bcc82e3043c8c509adac6b006 Mon Sep 17 00:00:00 2001 From: oeeve Date: Fri, 16 Jan 2026 07:53:56 +0000 Subject: [PATCH 6/6] updates to tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c00c108ca26..c34a9bd7b1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,5 +20,5 @@ jobs: - name: print go version run: | - go test ./... + go test -cover ./... exit 0