-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into harmony-1492
- Loading branch information
Showing
8 changed files
with
341 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
fixtures/uat.urs.earthdata.nasa.gov-443/168814650246494169
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
GET /api/user_groups/groups_for_user/undefined | ||
accept: application/json, text/plain, */* | ||
authorization: Bearer undefined | ||
|
||
HTTP/1.1 401 Unauthorized | ||
server: nginx/1.20.1 | ||
date: Fri, 30 Jun 2023 17:35:02 GMT | ||
content-type: application/json; charset=utf-8 | ||
transfer-encoding: chunked | ||
connection: close | ||
x-frame-options: SAMEORIGIN | ||
x-xss-protection: 1; mode=block | ||
x-content-type-options: nosniff | ||
x-download-options: noopen | ||
x-permitted-cross-domain-policies: none | ||
referrer-policy: strict-origin-when-cross-origin | ||
cache-control: no-store | ||
pragma: no-cache | ||
expires: Fri, 01 Jan 1990 00:00:00 GMT | ||
www-authenticate: Bearer realm="Earthdata Login",error="invalid_token" | ||
x-request-id: 4b0827fc-ca53-44b2-b710-3871b884a906 | ||
x-runtime: 0.002449 | ||
strict-transport-security: max-age=31536000 | ||
|
||
{"error":"invalid_token"} |
25 changes: 25 additions & 0 deletions
25
fixtures/uat.urs.earthdata.nasa.gov-443/168814650626380324
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
GET /api/user_groups/groups_for_user/jdoe | ||
accept: application/json, text/plain, */* | ||
authorization: Bearer fake_access | ||
|
||
HTTP/1.1 401 Unauthorized | ||
server: nginx/1.20.1 | ||
date: Fri, 30 Jun 2023 17:35:06 GMT | ||
content-type: application/json; charset=utf-8 | ||
transfer-encoding: chunked | ||
connection: close | ||
x-frame-options: SAMEORIGIN | ||
x-xss-protection: 1; mode=block | ||
x-content-type-options: nosniff | ||
x-download-options: noopen | ||
x-permitted-cross-domain-policies: none | ||
referrer-policy: strict-origin-when-cross-origin | ||
cache-control: no-store | ||
pragma: no-cache | ||
expires: Fri, 01 Jan 1990 00:00:00 GMT | ||
www-authenticate: Bearer realm="Earthdata Login",error="invalid_token" | ||
x-request-id: 6973563f-51b7-489f-a290-808fa43c783d | ||
x-runtime: 0.003604 | ||
strict-transport-security: max-age=31536000 | ||
|
||
{"error":"invalid_token"} |
25 changes: 25 additions & 0 deletions
25
fixtures/uat.urs.earthdata.nasa.gov-443/168814650828163749
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
GET /api/user_groups/groups_for_user/jdoe1 | ||
accept: application/json, text/plain, */* | ||
authorization: Bearer fake_access | ||
|
||
HTTP/1.1 401 Unauthorized | ||
server: nginx/1.20.1 | ||
date: Fri, 30 Jun 2023 17:35:08 GMT | ||
content-type: application/json; charset=utf-8 | ||
transfer-encoding: chunked | ||
connection: close | ||
x-frame-options: SAMEORIGIN | ||
x-xss-protection: 1; mode=block | ||
x-content-type-options: nosniff | ||
x-download-options: noopen | ||
x-permitted-cross-domain-policies: none | ||
referrer-policy: strict-origin-when-cross-origin | ||
cache-control: no-store | ||
pragma: no-cache | ||
expires: Fri, 01 Jan 1990 00:00:00 GMT | ||
www-authenticate: Bearer realm="Earthdata Login",error="invalid_token" | ||
x-request-id: 54172470-3017-4aaf-b79b-46c58357ea46 | ||
x-runtime: 0.002423 | ||
strict-transport-security: max-age=31536000 | ||
|
||
{"error":"invalid_token"} |
25 changes: 25 additions & 0 deletions
25
fixtures/uat.urs.earthdata.nasa.gov-443/168814650843835199
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
GET /api/user_groups/groups_for_user/jdoe2 | ||
accept: application/json, text/plain, */* | ||
authorization: Bearer fake_access | ||
|
||
HTTP/1.1 401 Unauthorized | ||
server: nginx/1.20.1 | ||
date: Fri, 30 Jun 2023 17:35:08 GMT | ||
content-type: application/json; charset=utf-8 | ||
transfer-encoding: chunked | ||
connection: close | ||
x-frame-options: SAMEORIGIN | ||
x-xss-protection: 1; mode=block | ||
x-content-type-options: nosniff | ||
x-download-options: noopen | ||
x-permitted-cross-domain-policies: none | ||
referrer-policy: strict-origin-when-cross-origin | ||
cache-control: no-store | ||
pragma: no-cache | ||
expires: Fri, 01 Jan 1990 00:00:00 GMT | ||
www-authenticate: Bearer realm="Earthdata Login",error="invalid_token" | ||
x-request-id: 8562feff-59e4-4376-984d-a066be03a2a4 | ||
x-runtime: 0.004536 | ||
strict-transport-security: max-age=31536000 | ||
|
||
{"error":"invalid_token"} |
25 changes: 25 additions & 0 deletions
25
fixtures/uat.urs.earthdata.nasa.gov-443/168814650857569725
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
GET /api/user_groups/groups_for_user/jdoe3 | ||
accept: application/json, text/plain, */* | ||
authorization: Bearer fake_access | ||
|
||
HTTP/1.1 401 Unauthorized | ||
server: nginx/1.20.1 | ||
date: Fri, 30 Jun 2023 17:35:08 GMT | ||
content-type: application/json; charset=utf-8 | ||
transfer-encoding: chunked | ||
connection: close | ||
x-frame-options: SAMEORIGIN | ||
x-xss-protection: 1; mode=block | ||
x-content-type-options: nosniff | ||
x-download-options: noopen | ||
x-permitted-cross-domain-policies: none | ||
referrer-policy: strict-origin-when-cross-origin | ||
cache-control: no-store | ||
pragma: no-cache | ||
expires: Fri, 01 Jan 1990 00:00:00 GMT | ||
www-authenticate: Bearer realm="Earthdata Login",error="invalid_token" | ||
x-request-id: 01bcd335-c61d-4f2f-8620-47e2566d206f | ||
x-runtime: 0.002942 | ||
strict-transport-security: max-age=31536000 | ||
|
||
{"error":"invalid_token"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
import { expect } from 'chai'; | ||
import { decrementRunningCount, getCount, incrementReadyAndDecrementRunningCounts, incrementRunningAndDecrementReadyCounts } from '../../app/models/user-work'; | ||
import db from '../../app/util/db'; | ||
import { truncateAll } from '../helpers/db'; | ||
import { createUserWorkRecord } from '../helpers/user-work'; | ||
|
||
describe('user_work table', async function () { | ||
describe('when creating a row and setting the ready and running counts to positive values', async function () { | ||
const userWork = createUserWorkRecord( { ready_count: 9, running_count: 5 }); | ||
before(async function () { | ||
await userWork.save(db); | ||
}); | ||
after(async function () { | ||
await truncateAll(); | ||
}); | ||
|
||
describe('when calling incrementRunningAndDecrementReadyCounts', async function () { | ||
before(async function () { | ||
await incrementRunningAndDecrementReadyCounts(db, userWork.job_id, userWork.service_id); | ||
}); | ||
|
||
it('adds one to the running_count', async function () { | ||
const runningCount = await getCount(db, userWork.job_id, userWork.service_id, 'running'); | ||
expect(runningCount).to.equal(6); | ||
}); | ||
it('subtracts one from the ready_count', async function () { | ||
const readyCount = await getCount(db, userWork.job_id, userWork.service_id, 'ready'); | ||
expect(readyCount).to.equal(8); | ||
}); | ||
}); | ||
|
||
describe('when calling incrementReadyAndDecrementRunningCounts', async function () { | ||
before(async function () { | ||
userWork.ready_count = 4; | ||
userWork.running_count = 8; | ||
await userWork.save(db); | ||
await incrementReadyAndDecrementRunningCounts(db, userWork.job_id, userWork.service_id); | ||
}); | ||
|
||
it('adds one to the ready_count', async function () { | ||
const readyCount = await getCount(db, userWork.job_id, userWork.service_id, 'ready'); | ||
expect(readyCount).to.equal(5); | ||
}); | ||
it('subtracts one from the running_count', async function () { | ||
const runningCount = await getCount(db, userWork.job_id, userWork.service_id, 'running'); | ||
expect(runningCount).to.equal(7); | ||
}); | ||
}); | ||
|
||
describe('when calling decrementRunningCount', async function () { | ||
before(async function () { | ||
userWork.ready_count = 4; | ||
userWork.running_count = 15; | ||
await userWork.save(db); | ||
await decrementRunningCount(db, userWork.job_id, userWork.service_id); | ||
}); | ||
|
||
it('does not change the ready_count', async function () { | ||
const readyCount = await getCount(db, userWork.job_id, userWork.service_id, 'ready'); | ||
expect(readyCount).to.equal(4); | ||
}); | ||
it('subtracts one from the running_count', async function () { | ||
const runningCount = await getCount(db, userWork.job_id, userWork.service_id, 'running'); | ||
expect(runningCount).to.equal(14); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when the ready count is a positive value, and the running count is 0', function () { | ||
const userWork = createUserWorkRecord( { ready_count: 9, running_count: 0 }); | ||
before(async function () { | ||
await userWork.save(db); | ||
}); | ||
after(async function () { | ||
await truncateAll(); | ||
}); | ||
|
||
describe('when calling incrementReadyAndDecrementRunningCounts', async function () { | ||
before(async function () { | ||
await incrementReadyAndDecrementRunningCounts(db, userWork.job_id, userWork.service_id); | ||
}); | ||
|
||
it('adds one to the ready_count', async function () { | ||
const readyCount = await getCount(db, userWork.job_id, userWork.service_id, 'ready'); | ||
expect(readyCount).to.equal(10); | ||
}); | ||
it('leaves the running_count set to zero instead of making it negative', async function () { | ||
const runningCount = await getCount(db, userWork.job_id, userWork.service_id, 'running'); | ||
expect(runningCount).to.equal(0); | ||
}); | ||
}); | ||
|
||
describe('when calling decrementRunningCount', async function () { | ||
before(async function () { | ||
userWork.ready_count = 9; | ||
userWork.running_count = 0; | ||
await userWork.save(db); | ||
await decrementRunningCount(db, userWork.job_id, userWork.service_id); | ||
}); | ||
|
||
it('leaves the running_count set to zero instead of making it negative', async function () { | ||
const runningCount = await getCount(db, userWork.job_id, userWork.service_id, 'running'); | ||
expect(runningCount).to.equal(0); | ||
}); | ||
}); | ||
|
||
describe('when calling incrementRunningAndDecrementReadyCounts', function () { | ||
before(async function () { | ||
userWork.ready_count = 9; | ||
userWork.running_count = 0; | ||
await userWork.save(db); | ||
await incrementRunningAndDecrementReadyCounts(db, userWork.job_id, userWork.service_id); | ||
}); | ||
|
||
it('adds one to the running_count', async function () { | ||
const runningCount = await getCount(db, userWork.job_id, userWork.service_id, 'running'); | ||
expect(runningCount).to.equal(1); | ||
}); | ||
it('subtracts one from the ready_count', async function () { | ||
const readyCount = await getCount(db, userWork.job_id, userWork.service_id, 'ready'); | ||
expect(readyCount).to.equal(8); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when the ready count is 0, and the running count is a positive value', async function () { | ||
const userWork = createUserWorkRecord( { ready_count: 0, running_count: 4 }); | ||
before(async function () { | ||
await userWork.save(db); | ||
}); | ||
after(async function () { | ||
await truncateAll(); | ||
}); | ||
|
||
describe('when calling incrementRunningAndDecrementReadyCounts', async function () { | ||
before(async function () { | ||
await incrementRunningAndDecrementReadyCounts(db, userWork.job_id, userWork.service_id); | ||
}); | ||
|
||
it('adds one to the running_count', async function () { | ||
const runningCount = await getCount(db, userWork.job_id, userWork.service_id, 'running'); | ||
expect(runningCount).to.equal(5); | ||
}); | ||
|
||
it('leaves the ready count set to zero instead of making it negative', async function () { | ||
const readyCount = await getCount(db, userWork.job_id, userWork.service_id, 'ready'); | ||
expect(readyCount).to.equal(0); | ||
}); | ||
}); | ||
|
||
describe('when calling incrementReadyAndDecrementRunningCounts', async function () { | ||
before(async function () { | ||
userWork.ready_count = 0; | ||
userWork.running_count = 4; | ||
await userWork.save(db); | ||
await incrementReadyAndDecrementRunningCounts(db, userWork.job_id, userWork.service_id); | ||
}); | ||
|
||
it('adds one to the ready_count', async function () { | ||
const readyCount = await getCount(db, userWork.job_id, userWork.service_id, 'ready'); | ||
expect(readyCount).to.equal(1); | ||
}); | ||
it('subtracts one from the running_count', async function () { | ||
const runningCount = await getCount(db, userWork.job_id, userWork.service_id, 'running'); | ||
expect(runningCount).to.equal(3); | ||
}); | ||
}); | ||
}); | ||
}); |