MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestExtractKey

Function TestExtractKey

api/middleware/auth_test.go:666–696  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

664}
665
666func TestExtractKey(t *testing.T) {
667 tests := []struct {
668 name string
669 header string
670 expected string
671 }{
672 {
673 name: "Valid key",
674 header: "test-key",
675 expected: "test-key",
676 },
677 {
678 name: "Empty key",
679 header: "",
680 expected: "",
681 },
682 }
683
684 for _, tt := range tests {
685 t.Run(tt.name, func(t *testing.T) {
686 c, _ := gin.CreateTestContext(httptest.NewRecorder())
687 c.Request = httptest.NewRequest("GET", "/", nil)
688 if tt.header != "" {
689 c.Request.Header.Set(KeyHeader, tt.header)
690 }
691
692 result := extractKey(c)
693 assert.Equal(t, tt.expected, result)
694 })
695 }
696}
697
698func TestHasPermission(t *testing.T) {
699 tests := []struct {

Callers

nothing calls this directly

Calls 2

extractKeyFunction · 0.85
SetMethod · 0.65

Tested by

no test coverage detected