Add CarrierNode project attribution
This commit is contained in:
1 parent
87cb39c04c
commit
2d8f138215
2 files changed
+29
No files matched your search
@@ -30,6 +30,26 @@ func TestListFilesMergesAcrossInstances(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestsCarryProjectAttribution(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if got := r.Header.Get("X-Internal-Auth"); got != "secret" {
|
||||
t.Fatalf("X-Internal-Auth = %q, want secret", got)
|
||||
}
|
||||
if got := r.Header.Get("X-Project-Key"); got != "ContentScanner" {
|
||||
t.Fatalf("X-Project-Key = %q, want ContentScanner", got)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"files":[]}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := New("secret", func(ctx context.Context) string { return server.URL })
|
||||
client.ProjectKey = "ContentScanner"
|
||||
if _, err := client.ListFiles(context.Background(), "", false, 0); err != nil {
|
||||
t.Fatalf("ListFiles error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListFilesSkipsUnreachableInstance(t *testing.T) {
|
||||
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
Reference in new issue
Block a user