mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-12 23:38:50 +00:00
- Added Olric cache server integration, including configuration options for Olric servers and timeout settings. - Implemented HTTP handlers for cache operations: health check, get, put, delete, and scan. - Enhanced Makefile with commands to run the Olric server and manage its configuration. - Updated README and setup scripts to include Olric installation and configuration instructions. - Introduced tests for cache handlers to ensure proper functionality and error handling.
29 lines
666 B
Go
29 lines
666 B
Go
package gateway
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestExtractAPIKey(t *testing.T) {
|
|
r := httptest.NewRequest(http.MethodGet, "/", nil)
|
|
r.Header.Set("Authorization", "Bearer ak_foo:ns")
|
|
if got := extractAPIKey(r); got != "ak_foo:ns" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
r.Header.Set("Authorization", "ApiKey ak2")
|
|
if got := extractAPIKey(r); got != "ak2" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
r.Header.Set("Authorization", "ak3raw")
|
|
if got := extractAPIKey(r); got != "ak3raw" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
r.Header = http.Header{}
|
|
r.Header.Set("X-API-Key", "xkey")
|
|
if got := extractAPIKey(r); got != "xkey" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|