feat(t222): add freight ingestion admin flow
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -158,6 +159,36 @@ func TestBuildRouterRegistersProtectedLogoutRoute(t *testing.T) {
|
||||
response.Header().Get("Location"),
|
||||
)
|
||||
}
|
||||
for _, target := range []string{"/freight", "/freight/import"} {
|
||||
request = httptest.NewRequest(http.MethodGet, target, nil)
|
||||
response = httptest.NewRecorder()
|
||||
router.ServeHTTP(response, request)
|
||||
if response.Code != http.StatusSeeOther ||
|
||||
response.Header().Get("Location") !=
|
||||
"/login?next="+url.QueryEscape(target) {
|
||||
t.Fatalf(
|
||||
"%s status/location = %d / %q",
|
||||
target,
|
||||
response.Code,
|
||||
response.Header().Get("Location"),
|
||||
)
|
||||
}
|
||||
}
|
||||
request = httptest.NewRequest(
|
||||
http.MethodGet,
|
||||
"/api/v1/freight-orders",
|
||||
nil,
|
||||
)
|
||||
response = httptest.NewRecorder()
|
||||
router.ServeHTTP(response, request)
|
||||
if response.Code != http.StatusUnauthorized ||
|
||||
response.Header().Get("Cache-Control") != "no-store" {
|
||||
t.Fatalf(
|
||||
"freight API status/cache = %d / %q",
|
||||
response.Code,
|
||||
response.Header().Get("Cache-Control"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
type stubMigrationStatusReader struct {
|
||||
|
||||
Reference in New Issue
Block a user