Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
updated unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
poornima-metron committed May 10, 2024
1 parent c58dd86 commit 5644be2
Show file tree
Hide file tree
Showing 9 changed files with 1,930 additions and 6 deletions.
37 changes: 32 additions & 5 deletions src/getStepStartStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,18 @@ import { WebSecurityScannerSteps } from './steps/web-security-scanner/constants'
import { IntegrationConfig } from './types';
import { isMasterOrganizationInstance } from './utils/isMasterOrganizationInstance';
import { isSingleProjectInstance } from './utils/isSingleProjectInstance';
import { STEP_GOOGLE_CLOUD_DATAFLOW_JOB } from './steps/data-flow/constants';
import {
STEP_GOOGLE_CLOUD_DATAFLOW_JOB,
STEP_GOOGLE_CLOUD_DATAFLOW,
STEP_GOOGLE_CLOUD_DATAFLOW_DATASTORE,
STEP_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT,
STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW_JOB,
STEP_GOOGLE_CLOUD_DATAFLOW_JOB_HAS_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT,
STEP_GOOGLE_CLOUD_DATAFLOW_JOB_USES_GOOGLE_CLOUD_DATAFLOW_DATASTORE,
// STEP_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT_USES_GOOGLE_PUBSUB_TOPIC,
STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW,
STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW_DATASTORE
} from './steps/data-flow/constants';

function makeStepStartStates(
stepIds: string[],
Expand Down Expand Up @@ -244,9 +255,8 @@ export default async function getStepStartStates(

logger.publishEvent({
name: 'integration_config',
description: `Starting Google Cloud integration with service account (email=${
config.serviceAccountKeyConfig.client_email
}, configureOrganizationProjects=${!!config.configureOrganizationProjects})`,
description: `Starting Google Cloud integration with service account (email=${config.serviceAccountKeyConfig.client_email
}, configureOrganizationProjects=${!!config.configureOrganizationProjects})`,
});

const masterOrgInstance = isMasterOrganizationInstance(config);
Expand Down Expand Up @@ -334,7 +344,15 @@ function getDefaultStepStartStates(params: {
[STEP_AUDIT_CONFIG_IAM_POLICY]: {
disabled: !!config.configureOrganizationProjects,
},
[STEP_GOOGLE_CLOUD_DATAFLOW_JOB]: { disabled: false },
[STEP_GOOGLE_CLOUD_DATAFLOW]: { disabled: false },
[STEP_GOOGLE_CLOUD_DATAFLOW_DATASTORE]: { disabled: false },
[STEP_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT]: { disabled: false },
[STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW_JOB]: { disabled: false },
[STEP_GOOGLE_CLOUD_DATAFLOW_JOB_HAS_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT]: { disabled: false },
[STEP_GOOGLE_CLOUD_DATAFLOW_JOB_USES_GOOGLE_CLOUD_DATAFLOW_DATASTORE]: { disabled: false },
// [STEP_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT_USES_GOOGLE_PUBSUB_TOPIC]: { disabled: false },
[STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW]: { disabled: false },
[STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW_DATASTORE]: { disabled: false },
[STEP_COMPUTE_DISKS]: { disabled: false },
[STEP_COMPUTE_REGION_DISKS]: { disabled: false },
[STEP_COMPUTE_IMAGES]: { disabled: false },
Expand Down Expand Up @@ -651,6 +669,15 @@ async function getStepStartStatesUsingServiceEnablements(params: {
? { disabled: true }
: createStepStartState(ServiceUsageName.RESOURCE_MANAGER),
[STEP_GOOGLE_CLOUD_DATAFLOW_JOB]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_GOOGLE_CLOUD_DATAFLOW]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_GOOGLE_CLOUD_DATAFLOW_DATASTORE]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW_JOB]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_GOOGLE_CLOUD_DATAFLOW_JOB_HAS_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_GOOGLE_CLOUD_DATAFLOW_JOB_USES_GOOGLE_CLOUD_DATAFLOW_DATASTORE]: createStepStartState(ServiceUsageName.DATA_FLOW),
// [STEP_GOOGLE_CLOUD_DATAFLOW_SNAPSHOT_USES_GOOGLE_PUBSUB_TOPIC]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_GOOGLE_CLOUD_PROJECT_HAS_GOOGLE_CLOUD_DATAFLOW_DATASTORE]: createStepStartState(ServiceUsageName.DATA_FLOW),
[STEP_COMPUTE_DISKS]: createStepStartState(ServiceUsageName.COMPUTE),
[STEP_COMPUTE_REGION_DISKS]: createStepStartState(ServiceUsageName.COMPUTE),
[STEP_COMPUTE_IMAGES]: createStepStartState(ServiceUsageName.COMPUTE),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
{
"log": {
"_recordingName": "fetch-google-cloud-dataflow-job-uses-google-cloud-dataflow-datastore",
"creator": {
"comment": "persister:JupiterOneIntegationFSPersister",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "acea721c8193b51ced888cae721cc423",
"_order": 0,
"cache": {},
"request": {
"bodySize": 727,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "content-type",
"value": "application/x-www-form-urlencoded"
},
{
"_fromType": "array",
"name": "user-agent",
"value": "google-api-nodejs-client/9.4.1"
},
{
"_fromType": "array",
"name": "x-goog-api-client",
"value": "gl-node/18.17.0"
},
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-length",
"value": "727"
},
{
"_fromType": "array",
"name": "accept-encoding",
"value": "gzip,deflate"
},
{
"name": "host",
"value": "www.googleapis.com"
}
],
"headersSize": 293,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/x-www-form-urlencoded",
"params": [],
"text": "[REDACTED]"
},
"queryString": [],
"url": "https://www.googleapis.com/oauth2/v4/token"
},
"response": {
"bodySize": 1222,
"content": {
"encoding": "utf-8",
"mimeType": "application/json; charset=UTF-8",
"size": 1222,
"text": "{\"access_token\":\"[REDACTED]\",\"expires_in\":9999,\"token_type\":\"Bearer\"}"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json; charset=UTF-8"
},
{
"name": "vary",
"value": "Origin, X-Origin, Referer"
},
{
"name": "date",
"value": "Tue, 07 May 2024 12:39:39 GMT"
},
{
"name": "server",
"value": "scaffolding on HTTPServer2"
},
{
"name": "cache-control",
"value": "private"
},
{
"name": "x-xss-protection",
"value": "0"
},
{
"name": "x-frame-options",
"value": "SAMEORIGIN"
},
{
"name": "x-content-type-options",
"value": "nosniff"
},
{
"name": "alt-svc",
"value": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"
},
{
"name": "connection",
"value": "close"
}
],
"headersSize": 390,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-05-07T12:39:38.864Z",
"time": 187,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 187
}
},
{
"_id": "45fdb1f844a17b6d6ec371710879c815",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "x-goog-api-client",
"value": "gdcl/7.0.1 gl-node/18.17.0"
},
{
"_fromType": "array",
"name": "accept-encoding",
"value": "gzip"
},
{
"_fromType": "array",
"name": "user-agent",
"value": "google-api-nodejs-client/7.0.1 (gzip)"
},
{
"_fromType": "array",
"name": "authorization",
"value": "[REDACTED]"
},
{
"_fromType": "array",
"name": "accept",
"value": "*/*"
},
{
"name": "host",
"value": "dataflow.googleapis.com"
}
],
"headersSize": 1305,
"httpVersion": "HTTP/1.1",
"method": "GET",
"queryString": [],
"url": "https://dataflow.googleapis.com/v1b3/projects/j1-gc-integration-dev-v3/jobs"
},
"response": {
"bodySize": 763,
"content": {
"encoding": "utf-8",
"mimeType": "application/json; charset=UTF-8",
"size": 763,
"text": "{\"jobs\":[{\"id\":\"2024-05-02_05_25_02-17305733872805367843\",\"projectId\":\"j1-gc-integration-dev-v3\",\"name\":\"test-job3\",\"type\":\"JOB_TYPE_BATCH\",\"currentState\":\"JOB_STATE_FAILED\",\"currentStateTime\":\"2024-05-02T13:28:54.170517Z\",\"createTime\":\"2024-05-02T12:25:06.098727Z\",\"location\":\"us-central1\",\"jobMetadata\":{\"sdkVersion\":{\"version\":\"2.55.1\",\"versionDisplayName\":\"Apache Beam SDK for Java\",\"sdkSupportStatus\":\"SUPPORTED\"}},\"startTime\":\"2024-05-02T12:25:06.098727Z\"},{\"id\":\"2024-04-29_06_54_21-11420805499054724452\",\"projectId\":\"j1-gc-integration-dev-v3\",\"name\":\"test-metron-job2\",\"currentState\":\"JOB_STATE_FAILED\",\"currentStateTime\":\"2024-04-29T14:01:46.604199Z\",\"createTime\":\"2024-04-29T13:54:22.225266Z\",\"location\":\"us-central1\",\"startTime\":\"2024-04-29T13:54:22.225266Z\"},{\"id\":\"2024-04-29_06_40_47-701576625030004708\",\"projectId\":\"j1-gc-integration-dev-v3\",\"name\":\"test-metron-job1\",\"currentState\":\"JOB_STATE_FAILED\",\"currentStateTime\":\"2024-04-29T13:46:31.741443Z\",\"createTime\":\"2024-04-29T13:40:48.311738Z\",\"location\":\"us-central1\",\"startTime\":\"2024-04-29T13:40:48.311738Z\"}]}"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json; charset=UTF-8"
},
{
"name": "vary",
"value": "Origin, X-Origin, Referer"
},
{
"name": "date",
"value": "Tue, 07 May 2024 12:39:40 GMT"
},
{
"name": "server",
"value": "ESF"
},
{
"name": "cache-control",
"value": "private"
},
{
"name": "x-xss-protection",
"value": "0"
},
{
"name": "x-frame-options",
"value": "SAMEORIGIN"
},
{
"name": "x-content-type-options",
"value": "nosniff"
},
{
"name": "alt-svc",
"value": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"
},
{
"name": "connection",
"value": "close"
}
],
"headersSize": 367,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-05-07T12:39:39.060Z",
"time": 1774,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 1774
}
}
],
"pages": [],
"version": "1.2"
}
}
Loading

0 comments on commit 5644be2

Please sign in to comment.