Skip to content

Commit

Permalink
Switch tests to the same package as plugin so it can be used directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jadolg committed Jul 23, 2024
1 parent 10a94ae commit af8f2d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
env:
GO_VERSION: 1.22
GOLANGCI_LINT_VERSION: v1.59.1
YAEGI_VERSION: v0.14.2
YAEGI_VERSION: v0.16.1
CGO_ENABLED: 0
defaults:
run:
Expand Down
12 changes: 5 additions & 7 deletions plugin_test.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
package plugin_test
package plugin

import (
"context"
"io"
"net/http"
"net/http/httptest"
"testing"

plugin "github.com/RiskIdent/traefik-tls-headers-plugin"
)

func TestInvalidConfig(t *testing.T) {
cfg := plugin.CreateConfig()
cfg := CreateConfig()
next := http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
_, err := plugin.New(context.Background(), next, cfg, "traefik-tls-headers-plugin")
_, err := New(context.Background(), next, cfg, "traefik-tls-headers-plugin")
if err == nil {
t.Fatal("expected error")
}
}

func TestTLSCipher(t *testing.T) {
cfg := plugin.CreateConfig()
cfg := CreateConfig()
cfg.Headers.Cipher = "X-TLS-Cipher"
next := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
assertHeader(t, r.Header, "X-TLS-Cipher", "TLS_AES_128_GCM_SHA256")
})
handler, err := plugin.New(context.Background(), next, cfg, "traefik-tls-headers-plugin")
handler, err := New(context.Background(), next, cfg, "traefik-tls-headers-plugin")
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit af8f2d5

Please sign in to comment.