-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bump-grafana-plugin-sdk-go-251
- Loading branch information
Showing
12 changed files
with
134 additions
and
40 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package infinity | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestGetQueryReqHeader(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
requestHeaders map[string]string | ||
headerName string | ||
expected string | ||
}{ | ||
{ | ||
name: "Authorization header exact match", | ||
requestHeaders: map[string]string{ | ||
HeaderKeyAuthorization: "Bearer token", | ||
}, | ||
headerName: HeaderKeyAuthorization, | ||
expected: "Bearer token", | ||
}, | ||
{ | ||
name: "Authorization header case insensitive match", | ||
requestHeaders: map[string]string{ | ||
strings.ToLower(HeaderKeyAuthorization): "Bearer token", | ||
}, | ||
headerName: HeaderKeyAuthorization, | ||
expected: "Bearer token", | ||
}, | ||
{ | ||
name: "X-Id-Token header exact match", | ||
requestHeaders: map[string]string{ | ||
HeaderKeyIdToken: "some-id-token", | ||
}, | ||
headerName: HeaderKeyIdToken, | ||
expected: "some-id-token", | ||
}, | ||
{ | ||
name: "X-Id-Token header case insensitive match", | ||
requestHeaders: map[string]string{ | ||
strings.ToLower(HeaderKeyIdToken): "some-id-token", | ||
}, | ||
headerName: HeaderKeyIdToken, | ||
expected: "some-id-token", | ||
}, | ||
{ | ||
name: "X-Id-Token header case with ID capitalization", | ||
requestHeaders: map[string]string{ | ||
"X-ID-Token": "some-id-token", | ||
}, | ||
headerName: HeaderKeyIdToken, | ||
expected: "some-id-token", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := getQueryReqHeader(tt.requestHeaders, tt.headerName) | ||
if got != tt.expected { | ||
t.Errorf("getQueryReqHeader() = %v, expected %v", got, tt.expected) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters