fix(e2e): add auth headers to jobs update/delete tests
This commit is contained in:
parent
bb970f4a74
commit
2fafd5ab37
1 changed files with 14 additions and 0 deletions
|
|
@ -255,6 +255,10 @@ func TestE2E_Jobs_Update(t *testing.T) {
|
||||||
companyID, userID := setupTestCompanyAndUser(t)
|
companyID, userID := setupTestCompanyAndUser(t)
|
||||||
defer cleanupTestCompanyAndUser(t, companyID, userID)
|
defer cleanupTestCompanyAndUser(t, companyID, userID)
|
||||||
|
|
||||||
|
// Generate and set auth token
|
||||||
|
token := createAuthToken(t, userID, companyID)
|
||||||
|
client.setAuthToken(token)
|
||||||
|
|
||||||
// Create a test job
|
// Create a test job
|
||||||
jobID := createTestJob(t, companyID, userID, "E2E Test Job for Update")
|
jobID := createTestJob(t, companyID, userID, "E2E Test Job for Update")
|
||||||
defer database.DB.Exec("DELETE FROM jobs WHERE id = $1", jobID)
|
defer database.DB.Exec("DELETE FROM jobs WHERE id = $1", jobID)
|
||||||
|
|
@ -309,6 +313,10 @@ func TestE2E_Jobs_Delete(t *testing.T) {
|
||||||
companyID, userID := setupTestCompanyAndUser(t)
|
companyID, userID := setupTestCompanyAndUser(t)
|
||||||
defer cleanupTestCompanyAndUser(t, companyID, userID)
|
defer cleanupTestCompanyAndUser(t, companyID, userID)
|
||||||
|
|
||||||
|
// Generate and set auth token
|
||||||
|
token := createAuthToken(t, userID, companyID)
|
||||||
|
client.setAuthToken(token)
|
||||||
|
|
||||||
// Create a test job to delete
|
// Create a test job to delete
|
||||||
jobID := createTestJob(t, companyID, userID, "E2E Test Job to Delete")
|
jobID := createTestJob(t, companyID, userID, "E2E Test Job to Delete")
|
||||||
|
|
||||||
|
|
@ -419,8 +427,14 @@ func TestE2E_Jobs_InvalidInput(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("CreateJobInvalidJSON", func(t *testing.T) {
|
t.Run("CreateJobInvalidJSON", func(t *testing.T) {
|
||||||
|
// Need auth for POST
|
||||||
|
companyID, userID := setupTestCompanyAndUser(t)
|
||||||
|
defer cleanupTestCompanyAndUser(t, companyID, userID)
|
||||||
|
token := createAuthToken(t, userID, companyID)
|
||||||
|
|
||||||
req, _ := http.NewRequest("POST", testServer.URL+"/api/v1/jobs", nil)
|
req, _ := http.NewRequest("POST", testServer.URL+"/api/v1/jobs", nil)
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("Authorization", "Bearer "+token)
|
||||||
req.Body = http.NoBody
|
req.Body = http.NoBody
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue