ci: expand shared package validation and test coverage
- Add lint, formatting, vet, and publish workflow checks - Run Go database tests with PostgreSQL and add Java tests - Make consumer sync opt-in; update docs and Go dependency
This commit is contained in:
1 parent
937f51b4fb
commit
0ff94f9b10
107 files changed
+10124
-410
No files matched your search
@@ -149,3 +149,26 @@ func TestHandlerAppliesPushedInfo(t *testing.T) {
|
||||
t.Fatal("response echoed the ContentScanner secret")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerRejectsNonHTTPURLsWithoutChangingStore(t *testing.T) {
|
||||
store := NewStore(Info{AuthGuardURL: "http://auth.example.com"})
|
||||
handler := Handler("s3cret", store)
|
||||
for _, bad := range []Info{
|
||||
{AuthGuardURL: "javascript:alert(1)"},
|
||||
{AuthGuardURL: "auth.example.com"},
|
||||
{CarrierNodeURLs: []string{"http://carrier.example.com", "file:///etc/passwd"}},
|
||||
{ContentScannerURL: "http://"},
|
||||
} {
|
||||
body, _ := json.Marshal(bad)
|
||||
req := httptest.NewRequest(http.MethodPut, "/api/core-services/internal", bytes.NewReader(body))
|
||||
req.Header.Set("X-Internal-Auth", "s3cret")
|
||||
rec := httptest.NewRecorder()
|
||||
handler(rec, req)
|
||||
if rec.Code != http.StatusBadRequest {
|
||||
t.Fatalf("status = %d for %+v, want 400", rec.Code, bad)
|
||||
}
|
||||
}
|
||||
if got := store.Get(); got.AuthGuardURL != "http://auth.example.com" || len(got.CarrierNodeURLs) != 0 {
|
||||
t.Fatalf("store changed by a rejected push: %+v", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user