Skip to content

Commit

Permalink
check auth token insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
consolethinks committed Oct 18, 2024
1 parent ca8c254 commit adc4cb1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions datasetIngestor/ingestDataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ func TestSendIngestCommand(t *testing.T) {
}

// Mock user map
const token = "sometoken"
user := map[string]string{
"displayName": "test user",
"accessToken": token,
}

// Mock metaDataMap
Expand All @@ -70,10 +72,16 @@ func TestSendIngestCommand(t *testing.T) {
{Size: 400},
}

const expectedAuthHeaderValue = "Bearer " + token

// Create a mock server
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
// Respond with a fixed dataset ID when a new dataset is created
if strings.HasPrefix(req.URL.Path, "/datasets") {
authVal := req.Header.Get("Authorization")
if authVal != expectedAuthHeaderValue {
t.Errorf("Invalid Auth header value: %s", authVal)
}
rw.Write([]byte(`{"pid": "test-dataset-id"}`))
} else {
// Respond with a 200 status code when a new data block is created
Expand Down

0 comments on commit adc4cb1

Please sign in to comment.