diff --git a/ENV_CHANGELOG.md b/ENV_CHANGELOG.md index fa59db0f9..76cc09a13 100644 --- a/ENV_CHANGELOG.md +++ b/ENV_CHANGELOG.md @@ -2,6 +2,14 @@ Any changes to the environment variables will be documented in this file in chronological order with the most recent changes first. +# 2024-12-04 +### Added +- USE_EDL_CLIENT_APP - whether to use an EDL client application to enable admin and deployment endpoints and allow OAuth workflows. +- EDL_TOKEN - required if USE_EDL_CLIENT_APP is set to false. An EDL token to use for all requests to the CMR and to download data in backend services. + +### Changed +- OAUTH_CLIENT_ID, OAUTH_UID, OAUTH_PASSWORD, and OAUTH_REDIRECT_URI are no longer required if USE_EDL_CLIENT_APP is false. + # 2024-12-03 ### Added - Added enviroment defaults for Harmony SMAP L2 Gridding Service diff --git a/README.md b/README.md index 54847f034..24cdc4418 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This is the quickest way to get started with Harmony (by running Harmony in a co built-in Kubernetes cluster (including `kubectl`) which can be enabled in preferences. Minikube is a popular Linux alternative for running Kubernetes locally. * [openssl](https://www.openssl.org/) Read [this installation guide](https://github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md) if you're a Windows user and openssl is not installed on your machine already. * [envsubst](https://pypi.org/project/envsubst) - Used to substitute environment variable placeholders inside configuration files. -* [Earthdata Login application in UAT](docs/edl-requirement.md) +* [Earthdata Login token in UAT](https://uat.urs.earthdata.nasa.gov) - You will need to create an account and then use the "Generate Token" link from your profile page to obtain a token. 2. Download this repository (or download the zip file from GitHub) ```bash diff --git a/bin/bootstrap-harmony b/bin/bootstrap-harmony index 678b4d637..264ea16a6 100755 --- a/bin/bootstrap-harmony +++ b/bin/bootstrap-harmony @@ -23,6 +23,14 @@ else source .env fi +# Validate environment +if [ "${USE_EDL_CLIENT_APP}" == "false" ]; then + if [ -z "${EDL_TOKEN}" ]; then + echo "Error: EDL_TOKEN must be set when USE_EDL_CLIENT_APP is 'false'." + exit 1 + fi +fi + # Used to decide whether or not to run harmony in k8s export LOCAL_DEV export KUBE_CONTEXT diff --git a/bin/create-dotenv b/bin/create-dotenv index 97f0897f5..25f7b6ccd 100755 --- a/bin/create-dotenv +++ b/bin/create-dotenv @@ -20,29 +20,43 @@ else EOF cat <<-PROMPT_EDL - Running Harmony requires creating an Earthdata Login (EDL) application. If you need instructions for this or do not understand what this means, please contact the Harmony team for help. Once you have your EDL application created, please enter the credentials as prompted. + Harmony can optionally use a user created Earthdata Login (EDL) client application to enable access + to administrative routes such as deployment endpoints as well as directly accessing logs from the + workflow-ui. These features are not generally useful for locally testing services, and so creation + of an EDL client is not necessary. To simplify getting started you can instead provide an EDL token + that will be used. PROMPT_EDL if [ "$EXEC_CONTEXT" != "workflow" ]; then - echo "# See the \"OAuth 2 (Earthdata Login)\" section in the env-defaults file" >> .env - echo "# Contact a harmony developer if unsure what values to use" >> .env - # prompt for the users EDL app credentials - read -p "EDL Application Client ID: " OAUTH_CLIENT_ID - read -s -p "EDL Application UID: " OAUTH_UID - echo "" - read -s -p "EDL Application Password: " OAUTH_PASSWORD - echo "" + read -p "To provide an EDL client application respond 'y', otherwise to supply just an EDL token hit : " USE_EDL_CLIENT_APP + else + USE_EDL_CLIENT_APP="y" + fi + if [ "${USE_EDL_CLIENT_APP}" != "y" ]; then + read -s -p "EDL token to use for authentication (obtained using the Generate Token functionality from https://uat.urs.earthdata.nasa.gov/profile): " EDL_TOKEN + echo "# Note that EDL tokens expire. If the token is no longer valid obtain a new one from https://uat.urs.earthdata.nasa.gov/profile" >> .env + echo "EDL_TOKEN=$EDL_TOKEN" >> .env + echo "USE_EDL_CLIENT_APP=false" >> .env + else + echo "# See the \"OAuth 2 (Earthdata Login)\" section in the env-defaults file" >> .env + echo "# Contact a harmony developer if unsure what values to use" >> .env + # prompt for the users EDL app credentials + read -p "EDL Application Client ID: " OAUTH_CLIENT_ID + read -s -p "EDL Application UID: " OAUTH_UID + echo "" + read -s -p "EDL Application Password: " OAUTH_PASSWORD + echo "" + cat <<-OAUTH_EOF >> .env +OAUTH_CLIENT_ID=$OAUTH_CLIENT_ID +OAUTH_UID=$OAUTH_UID +OAUTH_PASSWORD=$OAUTH_PASSWORD +OAUTH_EOF fi - - cat <<-EOF >> .env - OAUTH_CLIENT_ID=$OAUTH_CLIENT_ID - OAUTH_UID=$OAUTH_UID - OAUTH_PASSWORD=$OAUTH_PASSWORD -EOF if [ "$EXEC_CONTEXT" != "workflow" ]; then + echo "" # prompt for LOCALLY_DEPLOYED_SERVICES - echo "Enter services to deploy (comma separated list):" + echo "Enter services to deploy (comma separated list)." read -p "Hit to use the default services: " LOCALLY_DEPLOYED_SERVICES # Add locally LOCALLY_DEPLOYED_SERVICES if it is defined (not zero length) diff --git a/docs/edl-requirement.md b/docs/edl-application.md similarity index 57% rename from docs/edl-requirement.md rename to docs/edl-application.md index 7639aa87e..17cb12b21 100644 --- a/docs/edl-requirement.md +++ b/docs/edl-application.md @@ -1,6 +1,8 @@ -# Earthdata Login Application Requirement +# Earthdata Login Application (Optional) -To use Earthdata Login with a locally running Harmony, you must first [set up a new application](https://wiki.earthdata.nasa.gov/display/EL/How+To+Register+An+Application) in the Earthdata Login UAT environment using the Earthdata Login UI. This is a four step process: +For most Harmony functionality an Earthdata Login (EDL) application is not required. However for developers that need to work on functionality including admin endpoints such as /service-image-tag, /admin/jobs, or /admin/workflow-ui an EDL client application is needed. + +To use an EDL client application with a locally running Harmony, you must first [set up a new application](https://wiki.earthdata.nasa.gov/display/EL/How+To+Register+An+Application) in the Earthdata Login **UAT** environment using the Earthdata Login UI. This is a four step process: 1. Request and receive permission to be an Application Creator 2. Create a local/dev Harmony Application in the EDL web interface @@ -9,4 +11,4 @@ To use Earthdata Login with a locally running Harmony, you must first [set up a Select "OAuth 2" as the application type. Set the redirect URL to http://localhost:3000/oauth2/redirect for local Harmony. Leave `Required User Information` and `Redirect Time for Earthdata Login Splash page` empty. Check the checkbox for `By checking this box, I confirm that my application is compatible with EDL policy`. Leave the other checkbox unchecked. Then create the new application. After the application is created, you can use the "manage" -> "App Groups" tab to add the "EOSDIS Enterprise" group to the application. This "EOSDIS Enterprise" group will allow CMR searches issued by Harmony to be able to use your Earthdata Login tokens. -If you have an .env file ready to go (see bin/create-dotenv), set `OAUTH_CLIENT_ID`, `OAUTH_UID` and `OAUTH_PASSWORD` with the information from your Earthdata Login application. If you are not ready to create a .env file, refer back to these values later on when you are ready to populate it. \ No newline at end of file +If you have an .env file ready to go (see bin/create-dotenv), set `OAUTH_CLIENT_ID`, `OAUTH_UID` and `OAUTH_PASSWORD` with the information from your Earthdata Login application. If you are not ready to create a .env file, refer back to these values later on when you are ready to populate it. If you previously set up your harmony environment to not use an EDL client be sure to remove `USE_EDL_CLIENT_APP` from your .env file to use the default setting, or set `USE_EDL_CLIENT_APP=true`. \ No newline at end of file diff --git a/docs/guides/develop.md b/docs/guides/develop.md index fbdcf6166..2ab80751a 100644 --- a/docs/guides/develop.md +++ b/docs/guides/develop.md @@ -22,7 +22,7 @@ Required: * The [AWS CLI](https://aws.amazon.com/cli/) - Used to interact with both localstack and real AWS accounts * [SQLite3 commandline](https://sqlite.org/index.html) - Used to create the local development and test databases. Install using your OS package manager, or [download precompiled binaries from SQLite](https://www.sqlite.org/download.html) * PostgreSQL (required by the pg-native library) - `brew install postgresql` on OSX -* [Earthdata Login application in UAT](../edl-requirement.md) +* [Earthdata Login application in UAT](../edl-application.md) * [envsubst](https://pypi.org/project/envsubst) - Used to substitute environment variable placeholders inside configuration files. * [openssl](https://www.openssl.org/) Read [this installation guide](https://github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md) if you're a Windows user and openssl is not installed on your machine already. diff --git a/services/harmony/app/frontends/service-image-tags.ts b/services/harmony/app/frontends/service-image-tags.ts index 7d05b1123..29ec178cb 100644 --- a/services/harmony/app/frontends/service-image-tags.ts +++ b/services/harmony/app/frontends/service-image-tags.ts @@ -556,7 +556,7 @@ export async function updateServiceImageTag( * @param res - The response object * @param _next - The next middleware in the chain */ -export async function getServiceImageTagState( +export async function getServiceDeploymentsState( req: HarmonyRequest, res: Response, _next: NextFunction, ): Promise { if (!hasCookieSecret(req) && ! await validateUserIsInDeployerOrCoreGroup(req, res)) return; @@ -571,7 +571,7 @@ export async function getServiceImageTagState( * @param req - The request object * @param res - The response object */ -export async function setServiceImageTagState( +export async function setServiceDeploymentsState( req: HarmonyRequest, res: Response, ): Promise { const validations = [ diff --git a/services/harmony/app/middleware/cmr-collection-reader.ts b/services/harmony/app/middleware/cmr-collection-reader.ts index 5d089363d..bbc5c5cd4 100644 --- a/services/harmony/app/middleware/cmr-collection-reader.ts +++ b/services/harmony/app/middleware/cmr-collection-reader.ts @@ -6,6 +6,7 @@ import HarmonyRequest from '../models/harmony-request'; import { listToText } from '@harmony/util/string'; import { EdlUserEulaInfo, verifyUserEula } from '../util/edl-api'; import RequestContext from '../models/request-context'; +import env from '../util/env'; // CMR Collection IDs separated by delimiters of single "+" or single whitespace // (some clients may translate + to space) @@ -39,26 +40,28 @@ async function loadVariablesForCollection(context: RequestContext, collection: C * @throws ServerError, ForbiddenError, NotFoundError */ async function verifyEulaAcceptance(collections: CmrCollection[], req: HarmonyRequest): Promise { - const acceptEulaUrls = []; - for (const collection of collections) { - if (collection.eula_identifiers) { - for (const eulaId of collection.eula_identifiers) { - const eulaInfo: EdlUserEulaInfo = await verifyUserEula(req.context, req.user, eulaId); - if (eulaInfo.statusCode == 404 && eulaInfo.acceptEulaUrl) { // EULA wasn't accepted - acceptEulaUrls.push(eulaInfo.acceptEulaUrl); - } else if (eulaInfo.statusCode == 404) { - req.context.logger.error(`EULA (${eulaId}) verfification failed with statusCode 404. Error: ${eulaInfo.error}`); - throw new NotFoundError(`EULA ${eulaId} could not be found.`); - } else if (eulaInfo.statusCode !== 200) { - req.context.logger.error(`EULA (${eulaId}) verfification failed. Error: ${eulaInfo.error}`); - throw new ServerError(`EULA (${eulaId}) verfification failed unexpectedly.`); + if (env.useEdlClientApp) { + const acceptEulaUrls = []; + for (const collection of collections) { + if (collection.eula_identifiers) { + for (const eulaId of collection.eula_identifiers) { + const eulaInfo: EdlUserEulaInfo = await verifyUserEula(req.context, req.user, eulaId); + if (eulaInfo.statusCode == 404 && eulaInfo.acceptEulaUrl) { // EULA wasn't accepted + acceptEulaUrls.push(eulaInfo.acceptEulaUrl); + } else if (eulaInfo.statusCode == 404) { + req.context.logger.error(`EULA (${eulaId}) verfification failed with statusCode 404. Error: ${eulaInfo.error}`); + throw new NotFoundError(`EULA ${eulaId} could not be found.`); + } else if (eulaInfo.statusCode !== 200) { + req.context.logger.error(`EULA (${eulaId}) verfification failed. Error: ${eulaInfo.error}`); + throw new ServerError(`EULA (${eulaId}) verfification failed unexpectedly.`); + } } } } - } - if (acceptEulaUrls.length > 0) { - throw new ForbiddenError('You may access the requested data by resubmitting your request ' + - `after accepting the following EULA(s): ${acceptEulaUrls.join(', ')}.`); + if (acceptEulaUrls.length > 0) { + throw new ForbiddenError('You may access the requested data by resubmitting your request ' + + `after accepting the following EULA(s): ${acceptEulaUrls.join(', ')}.`); + } } } diff --git a/services/harmony/app/middleware/earthdata-login-oauth-authorizer.ts b/services/harmony/app/middleware/earthdata-login-oauth-authorizer.ts index 8942927d0..ee37e9422 100644 --- a/services/harmony/app/middleware/earthdata-login-oauth-authorizer.ts +++ b/services/harmony/app/middleware/earthdata-login-oauth-authorizer.ts @@ -8,11 +8,13 @@ import { ForbiddenError, RequestValidationError } from '../util/errors'; import HarmonyRequest from '../models/harmony-request'; import env from '../util/env'; -const vars = ['OAUTH_CLIENT_ID', 'OAUTH_UID', 'OAUTH_PASSWORD', 'OAUTH_REDIRECT_URI', 'OAUTH_HOST', 'COOKIE_SECRET']; +if (process.env.USE_EDL_CLIENT_APP === 'true') { + const vars = ['OAUTH_CLIENT_ID', 'OAUTH_UID', 'OAUTH_PASSWORD', 'OAUTH_REDIRECT_URI', 'OAUTH_HOST']; -const missingVars = vars.filter((v) => !process.env[v]); -if (missingVars.length > 0) { - throw new Error(`Earthdata Login configuration error: You must set ${listToText(missingVars)} in the environment`); + const missingVars = vars.filter((v) => !process.env[v]); + if (missingVars.length > 0) { + throw new Error(`Earthdata Login configuration error: When USE_EDL_CLIENT_APP is true you must set ${listToText(missingVars)} in the environment`); + } } export const oauthOptions: ModuleOptions = { diff --git a/services/harmony/app/middleware/earthdata-login-skipped.ts b/services/harmony/app/middleware/earthdata-login-skipped.ts new file mode 100644 index 000000000..a9c5810e5 --- /dev/null +++ b/services/harmony/app/middleware/earthdata-login-skipped.ts @@ -0,0 +1,26 @@ +import HarmonyRequest from '../models/harmony-request'; +import env from '../util/env'; + +if (process.env.USE_EDL_CLIENT_APP === 'false' && !process.env.EDL_TOKEN) { + throw new Error( + 'Earthdata Login configuration error: You must set EDL_TOKEN in the environment ' + + 'when USE_EDL_CLIENT_APP is false', + ); +} + +/** + * Builds Express.js middleware for bypassing EDL client authentication. This should only + * be used for local testing and will limit harmony functionality to endpoints that do + * not require an EDL client to perform checks. EDL token verification will not be + * performed directly by the harmony app, but the EDL_TOKEN environment variable will + * be passed to CMR and to download sites when trying to retrieve data at which point + * those applications will validate the token. + * + * @returns Express.js middleware for doing EDL token authentication + */ +export default async function edlSkipped(req: HarmonyRequest, res, next): Promise { + req.user = 'anonymous'; + req.accessToken = env.edlToken; + req.authorized = true; + return next(); +} diff --git a/services/harmony/app/routers/router.ts b/services/harmony/app/routers/router.ts index 95cecb3ae..8d13e2ad0 100644 --- a/services/harmony/app/routers/router.ts +++ b/services/harmony/app/routers/router.ts @@ -29,7 +29,7 @@ import { setLogLevel } from '../frontends/configuration'; import getVersions from '../frontends/versions'; import serviceInvoker from '../backends/service-invoker'; import HarmonyRequest, { addRequestContextToOperation } from '../models/harmony-request'; -import { getServiceImageTag, getServiceImageTags, updateServiceImageTag, getServiceImageTagState, setServiceImageTagState, getServiceDeployment, getServiceDeployments } from '../frontends/service-image-tags'; +import { getServiceImageTag, getServiceImageTags, updateServiceImageTag, getServiceDeploymentsState, setServiceDeploymentsState, getServiceDeployment, getServiceDeployments } from '../frontends/service-image-tags'; import cmrCollectionReader = require('../middleware/cmr-collection-reader'); import cmrUmmCollectionReader = require('../middleware/cmr-umm-collection-reader'); import env from '../util/env'; @@ -44,6 +44,8 @@ import { getAdminHealth, getHealth } from '../frontends/health'; import handleLabelParameter from '../middleware/label'; import { addJobLabels, deleteJobLabels } from '../frontends/labels'; import handleJobIDParameter from '../middleware/job-id'; +import earthdataLoginSkipped from '../middleware/earthdata-login-skipped'; + export interface RouterConfig { PORT?: string | number; // The port to run the frontend server on BACKEND_PORT?: string | number; // The port to run the backend server on @@ -51,7 +53,7 @@ export interface RouterConfig { // True if we should run example services, false otherwise. Should be false // in production. Defaults to true until we have real HTTP services. EXAMPLE_SERVICES?: string; - skipEarthdataLogin?: string; // True if we should skip using EDL + USE_EDL_CLIENT_APP?: string; // True if we use the EDL client app USE_HTTPS?: string; // True if the server should use https } @@ -151,10 +153,10 @@ const authorizedRoutes = [ * Creates and returns an express.Router instance that has the middleware * and handlers necessary to respond to frontend service requests * - * @param skipEarthdataLogin - Opt to skip Earthdata Login + * @param USE_EDL_CLIENT_APP - Opt to skip Earthdata Login * @returns A router which can respond to frontend service requests */ -export default function router({ skipEarthdataLogin = 'false' }: RouterConfig): express.Router { +export default function router({ USE_EDL_CLIENT_APP = 'false' }: RouterConfig): express.Router { const result = express.Router(); const secret = process.env.COOKIE_SECRET; @@ -174,10 +176,11 @@ export default function router({ skipEarthdataLogin = 'false' }: RouterConfig): // a bucket. result.post(collectionPrefix('(ogc-api-coverages)'), asyncHandler(shapefileUpload())); - result.use(logged(earthdataLoginTokenAuthorizer(authorizedRoutes))); - - if (`${skipEarthdataLogin}` !== 'true') { + if (`${USE_EDL_CLIENT_APP}` !== 'false') { + result.use(logged(earthdataLoginTokenAuthorizer(authorizedRoutes))); result.use(logged(earthdataLoginOauthAuthorizer(authorizedRoutes))); + } else { + result.use(logged(earthdataLoginSkipped)); } result.use('/core/*', core); @@ -313,8 +316,8 @@ export default function router({ skipEarthdataLogin = 'false' }: RouterConfig): result.put('/service-image-tag/:service', jsonParser, asyncHandler(updateServiceImageTag)); result.get('/service-deployment', asyncHandler(getServiceDeployments)); result.get('/service-deployment/:id', asyncHandler(getServiceDeployment)); - result.get('/service-deployments-state', asyncHandler(getServiceImageTagState)); - result.put('/service-deployments-state', jsonParser, asyncHandler(setServiceImageTagState)); + result.get('/service-deployments-state', asyncHandler(getServiceDeploymentsState)); + result.put('/service-deployments-state', jsonParser, asyncHandler(setServiceDeploymentsState)); result.get('/*', () => { throw new NotFoundError('The requested page was not found.'); }); result.post('/*', () => { throw new NotFoundError('The requested POST page was not found.'); }); diff --git a/services/harmony/app/util/edl-api.ts b/services/harmony/app/util/edl-api.ts index 2a2d6a2fd..2f793e7be 100644 --- a/services/harmony/app/util/edl-api.ts +++ b/services/harmony/app/util/edl-api.ts @@ -113,6 +113,11 @@ export interface EdlGroupMembership { */ export async function getEdlGroupInformation(context: RequestContext, username: string) : Promise { + + if (!env.useEdlClientApp) { + return { isAdmin: false, isLogViewer: false, isServiceDeployer: false, hasCorePermissions: false }; + } + const groups = await getUserGroups(context, username); let isAdmin = false; if (groups.includes(env.adminGroupId)) { @@ -142,6 +147,8 @@ export async function getEdlGroupInformation(context: RequestContext, username: * @param req - the harmony request */ export async function isAdminUser(req: HarmonyRequest): Promise { + if (!env.useEdlClientApp) return false; + const isAdmin = req.context.isAdminAccess || (await getEdlGroupInformation(req.context, req.user)).isAdmin; return isAdmin; diff --git a/services/harmony/app/util/env.ts b/services/harmony/app/util/env.ts index 421f92b99..2dd619f98 100644 --- a/services/harmony/app/util/env.ts +++ b/services/harmony/app/util/env.ts @@ -16,16 +16,12 @@ class HarmonyServerEnv extends HarmonyEnv { @IsNotEmpty() adminGroupId: string; - @IsNotEmpty() oauthClientId: string; - @IsNotEmpty() oauthHost: string; - @IsNotEmpty() oauthPassword: string; - @IsNotEmpty() oauthUid: string; @IsNotEmpty() @@ -123,6 +119,11 @@ class HarmonyServerEnv extends HarmonyEnv { @IsBoolean() uiLabeling: boolean; + + @IsBoolean() + useEdlClientApp: boolean; + + edlToken: string; } const localPath = path.resolve(__dirname, '../../env-defaults'); diff --git a/services/harmony/env-defaults b/services/harmony/env-defaults index 9d417c559..495f77705 100644 --- a/services/harmony/env-defaults +++ b/services/harmony/env-defaults @@ -173,6 +173,14 @@ LABEL_FILTER_COMPLETION_COUNT=10 # For example, if OAUTH_HOST points to UAT EDL, downloading data from a # TEA endpoint that's integrated with PROD EDL will fail. +# Setting USE_EDL_CLIENT_APP to false and setting an EDL_TOKEN will prevent making +# use of any Earthdata login API calls and instead pass that EDL_TOKEN to CMR and +# backend service downloads. By bypassing EDL all admin features in harmony will be +# disabled since harmony will not authenticate with EDL using a client app. + +USE_EDL_CLIENT_APP=true +EDL_TOKEN= + OAUTH_CLIENT_ID= OAUTH_UID= OAUTH_PASSWORD= diff --git a/services/harmony/fixtures/uat.urs.earthdata.nasa.gov-443/17327209194184812 b/services/harmony/fixtures/uat.urs.earthdata.nasa.gov-443/17327209194184812 new file mode 100644 index 000000000..d8543b2d4 --- /dev/null +++ b/services/harmony/fixtures/uat.urs.earthdata.nasa.gov-443/17327209194184812 @@ -0,0 +1,26 @@ +GET /api/user_groups/groups_for_user/anonymous +accept: application/json, text/plain, */* +authorization: Bearer fake_access +accept-encoding: gzip, compress, deflate, br + +HTTP/1.1 401 Unauthorized +server: nginx/1.22.1 +date: Wed, 27 Nov 2024 15:21:59 GMT +content-type: application/json; charset=utf-8 +transfer-encoding: chunked +connection: keep-alive +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: 766e5d76-bc63-455b-bae5-f74129cad960 +x-runtime: 0.002251 +strict-transport-security: max-age=31536000 + +{"error":"invalid_token"} \ No newline at end of file diff --git a/services/harmony/test/aggregation-batching.ts b/services/harmony/test/aggregation-batching.ts index 58b11db0f..c51d837ff 100644 --- a/services/harmony/test/aggregation-batching.ts +++ b/services/harmony/test/aggregation-batching.ts @@ -53,7 +53,7 @@ async function getBatchItemsForWorkItem(workItem: WorkItem): Promise { } describe('when testing a batched aggregation service', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); const collection = 'C1243729749-EEDTEST'; describe('with only one batch that should be created', function () { let batchInputsStub; diff --git a/services/harmony/test/cloud-access.ts b/services/harmony/test/cloud-access.ts index 042aaf131..fc4582fd5 100644 --- a/services/harmony/test/cloud-access.ts +++ b/services/harmony/test/cloud-access.ts @@ -4,7 +4,7 @@ import hookServersStartStop from './helpers/servers'; import { hookCloudAccessJson, hookCloudAccessSh, hookStubAssumeRole, sampleCloudAccessShResponse } from './helpers/cloud-access'; describe('Cloud access', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookStubAssumeRole(); describe('When not authenticated', function () { diff --git a/services/harmony/test/configuration.ts b/services/harmony/test/configuration.ts index 948705351..1333cea01 100644 --- a/services/harmony/test/configuration.ts +++ b/services/harmony/test/configuration.ts @@ -5,7 +5,7 @@ import { hookConfigureLogLevel } from './helpers/configuration'; describe('/core/configuration', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('/log-level', function () { describe('when the user is part of the core permissions group', function () { describe('and makes a request using only the level parameter and a valid value', function () { @@ -13,13 +13,13 @@ describe('/core/configuration', function () { it('returns an HTTP success response', function () { expect(this.res.statusCode).to.equal(200); }); - }); + }); describe('and passes a valid parameter value with mixed case', function () { hookConfigureLogLevel({ username: 'coraline', query: { level: 'eRrOr' } }); it('returns an HTTP success response', function () { expect(this.res.statusCode).to.equal(200); }); - }); + }); describe('and passes in a bogus parameter', function () { hookConfigureLogLevel({ username: 'coraline', query: { bogus: 'error', level: 'error' } }); it('returns an HTTP 400 response', function () { @@ -30,7 +30,7 @@ describe('/core/configuration', function () { 'description': 'Error: Must set log level using a single query parameter (level).', }); }); - }); + }); describe('and passes in an invalid parameter value', function () { hookConfigureLogLevel({ username: 'coraline', query: { level: 'hi' } }); it('returns an HTTP 400 response', function () { @@ -42,7 +42,7 @@ describe('/core/configuration', function () { }); }); }); - }); + }); describe('when the user is not part of the core permissions group', function () { hookConfigureLogLevel({ username: 'tim' }); it('returns a 403 Forbidden HTTP response', function () { diff --git a/services/harmony/test/earthdata-login.ts b/services/harmony/test/earthdata-login.ts index 123720b63..514cd0756 100644 --- a/services/harmony/test/earthdata-login.ts +++ b/services/harmony/test/earthdata-login.ts @@ -18,7 +18,7 @@ const fakeUsername = 'testy_mctestface'; describe('Earthdata Login', function () { StubService.hookEach(); - hookServersStartStop({ skipEarthdataLogin: false }, false); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }, false); describe('Calls to authenticated resources', function () { describe('When a request provides no token', function () { @@ -491,6 +491,6 @@ describe('Earthdata Login', function () { expect(this.res.statusCode).to.equal(500); expect(this.res.text).to.include('Earthdata is currently unavailable'); }); - + }); }); diff --git a/services/harmony/test/edl-tokens.ts b/services/harmony/test/edl-tokens.ts index 80737a62b..f411d6321 100644 --- a/services/harmony/test/edl-tokens.ts +++ b/services/harmony/test/edl-tokens.ts @@ -15,7 +15,7 @@ describe('Earthdata login bearer token passing', function () { const username = 'joe'; // StubService.hookEach(); // StubService.hook({ params: { status: 'successful' } }); - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('Calls to authenticated resources', function () { describe('When providing a valid token', function () { StubService.hook({ params: { redirect: 'http://example.com' } }); diff --git a/services/harmony/test/eula-acceptance.ts b/services/harmony/test/eula-acceptance.ts index 8a29e2bc9..5d05dbba3 100644 --- a/services/harmony/test/eula-acceptance.ts +++ b/services/harmony/test/eula-acceptance.ts @@ -18,7 +18,7 @@ describe('EULA acceptance validation', function () { skipPreview: 'true', }; - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('When the collection has 2 unaccepted EULAS', function () { hookRangesetRequest( @@ -29,7 +29,7 @@ describe('EULA acceptance validation', function () { ); it('Provides accept EULA URLs', function () { - const description = 'Error: You may access the requested data by resubmitting your request after accepting the following EULA(s): ' + + const description = 'Error: You may access the requested data by resubmitting your request after accepting the following EULA(s): ' + 'https://uat.urs.earthdata.nasa.gov/accept_eula?eula_id=be7c8c07-65f7-4e63-a81d-78dfa187870e, ' + 'https://uat.urs.earthdata.nasa.gov/accept_eula?eula_id=a5242e69-dc27-455c-b2bc-1991af58f719.'; expect(JSON.parse(this.res.text).description).to.eq(description); @@ -49,7 +49,7 @@ describe('EULA acceptance validation', function () { ); it('Provides accept EULA URLs', function () { - const description = 'Error: You may access the requested data by resubmitting your request after accepting the following EULA(s): ' + + const description = 'Error: You may access the requested data by resubmitting your request after accepting the following EULA(s): ' + 'https://uat.urs.earthdata.nasa.gov/accept_eula?eula_id=be7c8c07-65f7-4e63-a81d-78dfa187870e, ' + 'https://uat.urs.earthdata.nasa.gov/accept_eula?eula_id=a5242e69-dc27-455c-b2bc-1991af58f719.'; expect(JSON.parse(this.res.text).description).to.eq(description); @@ -69,7 +69,7 @@ describe('EULA acceptance validation', function () { ); it('Provides accept EULA URLs', function () { - const description = 'Error: You may access the requested data by resubmitting your request after accepting the following EULA(s): ' + + const description = 'Error: You may access the requested data by resubmitting your request after accepting the following EULA(s): ' + 'https://uat.urs.earthdata.nasa.gov/accept_eula?eula_id=be7c8c07-65f7-4e63-a81d-78dfa187870e.'; expect(JSON.parse(this.res.text).description).to.eq(description); }); diff --git a/services/harmony/test/health.ts b/services/harmony/test/health.ts index 6112e2182..86c701fde 100644 --- a/services/harmony/test/health.ts +++ b/services/harmony/test/health.ts @@ -24,7 +24,7 @@ const databaseDownHealthResponse = { }; describe('Health endpoints', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('When calling /health', function () { describe('When not authenticated', function () { diff --git a/services/harmony/test/helpers/servers.ts b/services/harmony/test/helpers/servers.ts index c26d89cd9..1a858c676 100644 --- a/services/harmony/test/helpers/servers.ts +++ b/services/harmony/test/helpers/servers.ts @@ -12,12 +12,12 @@ process.env.EXAMPLE_SERVICES = 'true'; * * Important for tests: any tests that make a request and follow a redirect to the job status * page expect that the job can be shared with any user. If a job cannot be shared (collection - * is not public or has a EULA), you must set skipEarthdataLogin: false, supply a username + * is not public or has a EULA), you must set USE_EDL_CLIENT_APP: true, supply a username * when making the request, and supply the same username when following the redirect to the * job status. * * Example: - * `hookServersStartStop({ skipEarthdataLogin: false });` + * `hookServersStartStop({ USE_EDL_CLIENT_APP: true });` * `hookRangesetRequest('1.0.0', collection, 'all', { query, username: 'joe' });` * `hookRedirect('joe');` * @@ -25,15 +25,15 @@ process.env.EXAMPLE_SERVICES = 'true'; * @param stubOAuthClientCredentialsReq - Whether to replace OAuth client_credentials API calls to EDL * with a stub that returns a fake_access token */ -export default function hookServersStartStop(opts = { skipEarthdataLogin: true }, stubOAuthClientCredentialsReq = true): void { +export default function hookServersStartStop(opts = { USE_EDL_CLIENT_APP: false }, stubOAuthClientCredentialsReq = true): void { let servers = null; before(async function () { // Skip Earthdata Login unless the test says to do otherwise - const skipEdl = opts.skipEarthdataLogin ? 'true' : 'false'; + const useEdlClientApp = opts.USE_EDL_CLIENT_APP ? 'true' : 'false'; // Start Harmony on a random open port servers = await harmony.start({ EXAMPLE_SERVICES: 'true', - skipEarthdataLogin: skipEdl, + USE_EDL_CLIENT_APP: useEdlClientApp, startWorkflowTerminationListener: 'false', startWorkReaper: 'false', startWorkFailer: 'false', diff --git a/services/harmony/test/jobs/auto-pause-jobs.ts b/services/harmony/test/jobs/auto-pause-jobs.ts index cf17a0065..dba741e80 100644 --- a/services/harmony/test/jobs/auto-pause-jobs.ts +++ b/services/harmony/test/jobs/auto-pause-jobs.ts @@ -99,7 +99,7 @@ function previewingToPauseTest(username: string): void { } describe('Auto-pausing jobs', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); let sizeOfObjectStub; before(async function () { env.previewThreshold = 3; diff --git a/services/harmony/test/jobs/batch-status-change.ts b/services/harmony/test/jobs/batch-status-change.ts index f05128b22..ec6e1cd6b 100644 --- a/services/harmony/test/jobs/batch-status-change.ts +++ b/services/harmony/test/jobs/batch-status-change.ts @@ -15,7 +15,7 @@ import { JobStatus, Job } from '../../app/models/job'; describe('jobs/cancel, jobs/resume, jobs/skip-preview, jobs/resume', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('Canceling multiple jobs', function () { hookTransaction(); diff --git a/services/harmony/test/jobs/cancel-jobs.ts b/services/harmony/test/jobs/cancel-jobs.ts index 6f5f07417..385270c51 100644 --- a/services/harmony/test/jobs/cancel-jobs.ts +++ b/services/harmony/test/jobs/cancel-jobs.ts @@ -25,7 +25,7 @@ describe('Canceling a job - user endpoint', function () { }; for (const [httpMethod, cancelEndpointHook] of Object.entries(cancelEndpointHooks)) { describe(`Canceling using ${httpMethod}`, function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); const joeJob1 = buildJob({ username: 'joe' }); before(async function () { @@ -224,7 +224,7 @@ describe('Canceling a job - admin endpoint', function () { }; for (const [httpMethod, cancelEndpointHook] of Object.entries(cancelEndpointHooks)) { describe(`Canceling using ${httpMethod}`, function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); const joeJob1 = buildJob({ username: 'joe' }); before(async function () { diff --git a/services/harmony/test/jobs/job-sharing.ts b/services/harmony/test/jobs/job-sharing.ts index fe4532db2..db19e6cf5 100644 --- a/services/harmony/test/jobs/job-sharing.ts +++ b/services/harmony/test/jobs/job-sharing.ts @@ -83,7 +83,7 @@ const jobWithMultipleCollections = buildJob({ const jobIDWithMultipleCollections = jobWithMultipleCollections.requestId; describe('Sharing job results with someone other than its owner', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); before(async function () { diff --git a/services/harmony/test/jobs/job-status-pagination.ts b/services/harmony/test/jobs/job-status-pagination.ts index 2a1eba5f7..9feb0edd7 100644 --- a/services/harmony/test/jobs/job-status-pagination.ts +++ b/services/harmony/test/jobs/job-status-pagination.ts @@ -8,7 +8,7 @@ import db from '../../app/util/db'; import env from '../../app/util/env'; describe('Individual job status route - pagination', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); const links: JobLink[] = [] as JobLink[]; const aJob = buildJob({ username: 'joe', links }); diff --git a/services/harmony/test/jobs/jobs-listing.ts b/services/harmony/test/jobs/jobs-listing.ts index 20a168607..7b38994dd 100644 --- a/services/harmony/test/jobs/jobs-listing.ts +++ b/services/harmony/test/jobs/jobs-listing.ts @@ -59,7 +59,7 @@ const buzzJob1 = buildJob({ let defaultJobListPageSize; describe('Jobs listing route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('For a user who is not logged in', function () { before(async function () { this.res = await jobListing(this.frontend).redirects(0); diff --git a/services/harmony/test/jobs/jobs-status.ts b/services/harmony/test/jobs/jobs-status.ts index ba0079b43..12824d821 100644 --- a/services/harmony/test/jobs/jobs-status.ts +++ b/services/harmony/test/jobs/jobs-status.ts @@ -56,7 +56,7 @@ function itIncludesADataExpirationField(): void { describe('Individual job status route', function () { const aJobLabels = ['foo', 'bar', '000', 'z-label']; - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); before(async function () { await aJob.save(this.trx); diff --git a/services/harmony/test/jobs/pause-jobs.ts b/services/harmony/test/jobs/pause-jobs.ts index 144ea8242..f4460926e 100644 --- a/services/harmony/test/jobs/pause-jobs.ts +++ b/services/harmony/test/jobs/pause-jobs.ts @@ -340,7 +340,7 @@ describe('Pausing and resuming a job - user endpoint', function () { for (const [httpMethod, resumeEndpointHook] of Object.entries(resumeEndpointHooks)) { const pauseEndpointHook = pauseEndpointHooks[httpMethod]; describe(`Pausing and resuming using ${httpMethod}`, function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('Resuming a job', function () { let token; hookTransaction(); @@ -542,7 +542,7 @@ describe('Pausing and resuming a job - admin endpoint', function () { for (const [httpMethod, resumeEndpointHook] of Object.entries(resumeEndpointHooks)) { const pauseEndpointHook = pauseEndpointHooks[httpMethod]; describe(`Pausing and resuming using ${httpMethod}`, function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('Resuming a job', function () { hookTransaction(); const joeJob1 = buildJob({ username: normalUsername }); diff --git a/services/harmony/test/jobs/skip-job-preview.ts b/services/harmony/test/jobs/skip-job-preview.ts index 8d8341a40..76b1f5659 100644 --- a/services/harmony/test/jobs/skip-job-preview.ts +++ b/services/harmony/test/jobs/skip-job-preview.ts @@ -210,7 +210,7 @@ const encrypter = createEncrypter(env.sharedSecretKey); const decrypter = createDecrypter(env.sharedSecretKey); describe('Skipping job preview', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('User endpoint', function () { const skipPreviewEndpointHooks = { diff --git a/services/harmony/test/labels/jobs-listing-by-label.ts b/services/harmony/test/labels/jobs-listing-by-label.ts index 6dff28e7f..4b253140e 100644 --- a/services/harmony/test/labels/jobs-listing-by-label.ts +++ b/services/harmony/test/labels/jobs-listing-by-label.ts @@ -5,7 +5,7 @@ import hookServersStartStop from '../helpers/servers'; import db from '../../app/util/db'; describe('Get jobs listing by label', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); const joeJob1 = buildJob({ username: 'joe' }); const joeJob2 = buildJob({ username: 'joe' }); const jillJob1 = buildJob({ username: 'jill' }); diff --git a/services/harmony/test/labels/label_crud.ts b/services/harmony/test/labels/label_crud.ts index bf0e99e4b..a74d799f6 100644 --- a/services/harmony/test/labels/label_crud.ts +++ b/services/harmony/test/labels/label_crud.ts @@ -12,7 +12,7 @@ import { getRecentLabelsForUser } from '../../app/models/label'; describe('Get Labels', function () { const joeJob = buildJob({ username: 'joe' }); const jillJob = buildJob({ username: 'jill' }); - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); before(async function () { await truncateAll(); const trx = await db.transaction(); @@ -58,7 +58,7 @@ describe('Get Labels', function () { describe('Job label CRUD', function () { const envLabelsAllowListStub = stub(env, 'labelsAllowList').get(() => 'butt'); const envLabelsForbidListStub = stub(env, 'labelsForbidList').get(() => 'buzz'); - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); const joeJob1 = buildJob({ username: 'joe' }); before(async function () { diff --git a/services/harmony/test/ogc-api-coverages/get-coverage-rangeset-shapefile.ts b/services/harmony/test/ogc-api-coverages/get-coverage-rangeset-shapefile.ts index e87f892da..f188e3330 100644 --- a/services/harmony/test/ogc-api-coverages/get-coverage-rangeset-shapefile.ts +++ b/services/harmony/test/ogc-api-coverages/get-coverage-rangeset-shapefile.ts @@ -48,7 +48,7 @@ describe('OGC API Coverages - getCoverageRangeset with shapefile', function () { const variableName = 'red_var'; const version = '1.0.0'; - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); const cmrRespStr = fs.readFileSync('./test/resources/africa_shapefile_post_response.json'); const cmrResp = JSON.parse(cmrRespStr.toString()); diff --git a/services/harmony/test/parameters/concatenation.ts b/services/harmony/test/parameters/concatenation.ts index 7937b2fae..a1e9ea49a 100644 --- a/services/harmony/test/parameters/concatenation.ts +++ b/services/harmony/test/parameters/concatenation.ts @@ -12,7 +12,7 @@ describe('testing concatenation', function () { const serviceTag = 'ghcr.io/podaac/concise:sit'; describe('When passing the concatenate parameter', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('calling the backend service', function () { const query = { @@ -139,7 +139,7 @@ describe('testing concatenation', function () { const conciseImage = 'ghcr.io/podaac/concise:sit'; describe('When passing the concatenate parameter and spatial subsetting', function () { - hookServersStartStop( { skipEarthdataLogin: false }); + hookServersStartStop( { USE_EDL_CLIENT_APP: true }); const query = { concatenate: true, subset: 'lat(0:90)', diff --git a/services/harmony/test/parameters/label.ts b/services/harmony/test/parameters/label.ts index 1a305cd4f..a9e66142d 100644 --- a/services/harmony/test/parameters/label.ts +++ b/services/harmony/test/parameters/label.ts @@ -41,7 +41,7 @@ const hookPartials = { }; describe('labels', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); for (const apiType of Object.keys(hookPartials)) { describe(`${apiType}`, function () { diff --git a/services/harmony/test/request-metrics.ts b/services/harmony/test/request-metrics.ts index 85f05e519..eded03e64 100644 --- a/services/harmony/test/request-metrics.ts +++ b/services/harmony/test/request-metrics.ts @@ -60,7 +60,7 @@ describe('/admin/request-metrics', function () { const workflowStepRecords = workflowStepData.map(makePartialWorkflowStepRecord); const workItemRecords = workItemData.map(makePartialWorkItemRecord); - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); before(truncateAll); after(truncateAll); diff --git a/services/harmony/test/service-deployment.ts b/services/harmony/test/service-deployment.ts index 096b4f61d..ff2227d2b 100644 --- a/services/harmony/test/service-deployment.ts +++ b/services/harmony/test/service-deployment.ts @@ -42,7 +42,7 @@ describe('List service deployments endpoint', async function () { let failedServicesListing; let runningAndFooServiceListing; - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); before(async function () { diff --git a/services/harmony/test/service-image-tags.ts b/services/harmony/test/service-image-tags.ts index 3764b6600..337be0ece 100644 --- a/services/harmony/test/service-image-tags.ts +++ b/services/harmony/test/service-image-tags.ts @@ -237,7 +237,7 @@ describe('Service image endpoint', async function () { envStub.restore(); }); - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('List service images', async function () { describe('when a user is not in the EDL service deployers or core permissions groups', async function () { @@ -1189,7 +1189,7 @@ describe('Service image endpoint', async function () { }); describe('Service self-deployment successful', async function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('Update service image successful', function () { let execStub; @@ -1310,7 +1310,7 @@ describe('Service self-deployment successful', async function () { }); describe('Service self-deployment failure', async function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('Update service image failed', function () { let execStub; @@ -1422,7 +1422,7 @@ describe('get service deployments state with cookie-secret', async function () { process.env.COOKIE_SECRET = 'cookie-secret-value'; }); - hookServersStartStop({ skipEarthdataLogin: true }); + hookServersStartStop(); describe('when incorrect cookie-secret header is provided', async function () { before(async function () { @@ -1440,7 +1440,7 @@ describe('get service deployments state with cookie-secret', async function () { }); it('returns a meaningful error message', async function () { - expect(this.res.text).to.equal('User undefined does not have permission to access this resource'); + expect(this.res.text).to.equal('User anonymous does not have permission to access this resource'); }); }); @@ -1470,7 +1470,7 @@ describe('Update service deployments state with cookie-secret', async function ( process.env.COOKIE_SECRET = 'cookie-secret-value'; }); - hookServersStartStop({ skipEarthdataLogin: true }); + hookServersStartStop(); describe('when incorrect cookie-secret header is provided', async function () { before(async function () { @@ -1490,7 +1490,7 @@ describe('Update service deployments state with cookie-secret', async function ( }); it('returns a meaningful error message', async function () { - expect(this.res.text).to.equal('User undefined does not have permission to access this resource'); + expect(this.res.text).to.equal('User anonymous does not have permission to access this resource'); }); }); diff --git a/services/harmony/test/service-metrics-backends.ts b/services/harmony/test/service-metrics-backends.ts index d79f76d33..19684a567 100644 --- a/services/harmony/test/service-metrics-backends.ts +++ b/services/harmony/test/service-metrics-backends.ts @@ -65,7 +65,7 @@ async function createJobAndWorkItems(serviceID: string, jobStatus: JobStatus): P describe('Backend service metrics endpoint', function () { - hookServersStartStop({ skipEarthdataLogin: true }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('when hitting the service/metrics endpoint without serviceID parameter', function () { hookServiceMetrics(); diff --git a/services/harmony/test/service-results.ts b/services/harmony/test/service-results.ts index 1964c7867..4f1f6ce63 100644 --- a/services/harmony/test/service-results.ts +++ b/services/harmony/test/service-results.ts @@ -7,7 +7,7 @@ import { hookUrl } from './helpers/hooks'; import { FileStore } from '../app/util/object-store/file-store'; describe('service-results', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('createPublicPermalink', function () { it('returns Harmony permalink when given an S3 link prefixed with /public/', function () { diff --git a/services/harmony/test/stac/stac-item.ts b/services/harmony/test/stac/stac-item.ts index 60ec28957..42e4e4e3f 100644 --- a/services/harmony/test/stac/stac-item.ts +++ b/services/harmony/test/stac/stac-item.ts @@ -101,7 +101,7 @@ const completedNonStacJob = buildJob({ }); describe('STAC item route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); before(async function () { await runningJob.save(this.trx); diff --git a/services/harmony/test/stac/stac-pagination.ts b/services/harmony/test/stac/stac-pagination.ts index eed28d167..e15674f05 100644 --- a/services/harmony/test/stac/stac-pagination.ts +++ b/services/harmony/test/stac/stac-pagination.ts @@ -10,7 +10,7 @@ import db from '../../app/util/db'; import env from '../../app/util/env'; describe('STAC - pagination', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); const links: JobLink[] = [] as JobLink[]; const aJob = buildJob( diff --git a/services/harmony/test/stac/stac.ts b/services/harmony/test/stac/stac.ts index 4fb33a76d..7558208e1 100644 --- a/services/harmony/test/stac/stac.ts +++ b/services/harmony/test/stac/stac.ts @@ -48,7 +48,7 @@ const completedJobProps = { }; describe('STAC catalog route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); const runningJob = buildJob(runningJobProps); const completedJob = buildJob(completedJobProps); diff --git a/services/harmony/test/work-items/fair-queueing.ts b/services/harmony/test/work-items/fair-queueing.ts index bdaae45be..7c9ed4269 100644 --- a/services/harmony/test/work-items/fair-queueing.ts +++ b/services/harmony/test/work-items/fair-queueing.ts @@ -64,7 +64,7 @@ const workItemData = [ ]; describe('Fair Queueing', function () { - hookServersStartStop({ skipEarthdataLogin: true }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('When work is requested for a service and no work items are currently running', function () { const jobRecords = jobData.map(makePartialJobRecord); diff --git a/services/harmony/test/work-items/work-backends.ts b/services/harmony/test/work-items/work-backends.ts index 8181ea00e..34c123d42 100644 --- a/services/harmony/test/work-items/work-backends.ts +++ b/services/harmony/test/work-items/work-backends.ts @@ -42,7 +42,7 @@ describe('Work Backends', function () { operation: validOperation, } as Partial; - hookServersStartStop({ skipEarthdataLogin: true }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); describe('when getting a work item', function () { const runningJob = new Job({ diff --git a/services/harmony/test/workflow-ui/job.ts b/services/harmony/test/workflow-ui/job.ts index d9a86b3b9..e35411980 100644 --- a/services/harmony/test/workflow-ui/job.ts +++ b/services/harmony/test/workflow-ui/job.ts @@ -35,7 +35,7 @@ const shareableJob = buildJob({ }); describe('Workflow UI job route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); before(async function () { diff --git a/services/harmony/test/workflow-ui/jobs-table.ts b/services/harmony/test/workflow-ui/jobs-table.ts index aa14c1847..3a6f3a9a1 100644 --- a/services/harmony/test/workflow-ui/jobs-table.ts +++ b/services/harmony/test/workflow-ui/jobs-table.ts @@ -26,7 +26,7 @@ const allJobIds = [boJob1.jobID, boJob2.jobID, adamJob1.jobID, woodyJob1.jobID, const totalJobsCount = [boJob1, boJob2, adamJob1, woodyJob1, woodyJob2].length; describe('Workflow UI jobs table route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); let servicesStub: sinon.SinonStub; diff --git a/services/harmony/test/workflow-ui/jobs.ts b/services/harmony/test/workflow-ui/jobs.ts index 7b5c2af22..3dc50cdb3 100644 --- a/services/harmony/test/workflow-ui/jobs.ts +++ b/services/harmony/test/workflow-ui/jobs.ts @@ -91,7 +91,7 @@ const sidJob4 = buildJob({ }); describe('Workflow UI jobs route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); before(async function () { await truncateAll(); @@ -181,9 +181,9 @@ describe('Workflow UI jobs route', function () { }); it('displays the sorted labels for the user\'s jobs', function () { - const listing = this.res.text; + const listing = this.res.text; expect(listing).to.contain(mustache.render( - '{{#labels}} {{.}}{{/labels}}', + '{{#labels}} {{.}}{{/labels}}', { labels: ['1st-label', 'blue-label', 'yellow-label', 'z-last-label'] })); }); @@ -193,7 +193,7 @@ describe('Workflow UI jobs route', function () { }); }); - describe('who has 0 jobs', function () { + describe('who has 0 jobs', function () { hookWorkflowUIJobs({ username: 'eve' }); it('the paging descriptor makes sense', function () { const listing = this.res.text; @@ -601,10 +601,10 @@ describe('Workflow UI jobs route', function () { it('displays the labels for those jobs', function () { const listing = this.res.text; expect(listing).to.contain(mustache.render( - '{{#labels}} {{.}}{{/labels}}', + '{{#labels}} {{.}}{{/labels}}', { labels: ['1st-label', 'blue-label', 'yellow-label', 'z-last-label'] })); expect(listing).to.contain(mustache.render( - '{{#labels}} {{.}}{{/labels}}', + '{{#labels}} {{.}}{{/labels}}', { labels: ['label-1', 'label-2'] })); }); }); @@ -745,7 +745,7 @@ describe('Workflow UI jobs route', function () { const netcdfToZarrTd = mustache.render('{{service}}', { service: 'harmony/netcdf-to-zarr' }); const netcdfToZarrRegExp = new RegExp(netcdfToZarrTd, 'g'); expect((listing.match(netcdfToZarrRegExp) || []).length).to.equal(1); - + expect(listing).to.contain(`${JobStatus.FAILED.valueOf()}`); expect(listing).to.not.contain(`${JobStatus.SUCCESSFUL.valueOf()}`); expect(listing).to.not.contain(`${JobStatus.RUNNING.valueOf()}`); diff --git a/services/harmony/test/workflow-ui/links.ts b/services/harmony/test/workflow-ui/links.ts index 54536848b..73af4a771 100644 --- a/services/harmony/test/workflow-ui/links.ts +++ b/services/harmony/test/workflow-ui/links.ts @@ -33,7 +33,7 @@ const shareableJob = buildJob({ }); describe('Workflow UI job links route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); before(async function () { diff --git a/services/harmony/test/workflow-ui/log-viewer.ts b/services/harmony/test/workflow-ui/log-viewer.ts index 01dec0dd3..c548d16c2 100644 --- a/services/harmony/test/workflow-ui/log-viewer.ts +++ b/services/harmony/test/workflow-ui/log-viewer.ts @@ -32,7 +32,7 @@ const item1 = buildWorkItem( describe('Workflow UI directly accessing log files', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); before(async function () { await truncateAll(); diff --git a/services/harmony/test/workflow-ui/retry.ts b/services/harmony/test/workflow-ui/retry.ts index a6625d2b3..4c1ea2ce0 100644 --- a/services/harmony/test/workflow-ui/retry.ts +++ b/services/harmony/test/workflow-ui/retry.ts @@ -20,7 +20,7 @@ describe('Workflow UI retry', function () { const item1 = buildWorkItem({ jobID: job.jobID, status: WorkItemStatus.RUNNING, workflowStepIndex: 0, id: 1 }); const item2 = buildWorkItem({ jobID: job.jobID, status: WorkItemStatus.RUNNING, workflowStepIndex: 0, id: 2 }); - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); hookTransaction(); before(async function () { diff --git a/services/harmony/test/workflow-ui/work-items-table-row.ts b/services/harmony/test/workflow-ui/work-items-table-row.ts index d03f7f65c..f461d296c 100644 --- a/services/harmony/test/workflow-ui/work-items-table-row.ts +++ b/services/harmony/test/workflow-ui/work-items-table-row.ts @@ -65,7 +65,7 @@ const shareableJob = buildJob({ const shareableItem1 = buildWorkItem({ jobID: shareableJob.jobID, status: WorkItemStatus.RUNNING, id: 10 }); describe('Workflow UI work items table row route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); let retryLimit; before(async function () { diff --git a/services/harmony/test/workflow-ui/work-items-table.ts b/services/harmony/test/workflow-ui/work-items-table.ts index 099e4ff94..bbfe11e3d 100644 --- a/services/harmony/test/workflow-ui/work-items-table.ts +++ b/services/harmony/test/workflow-ui/work-items-table.ts @@ -79,7 +79,7 @@ const otherItem3 = buildWorkItem({ jobID: otherJob.jobID, status: WorkItemStatus const logsTableHeader = '>logs'; describe('Workflow UI work items table route', function () { - hookServersStartStop({ skipEarthdataLogin: false }); + hookServersStartStop({ USE_EDL_CLIENT_APP: true }); before(async function () { await truncateAll();