Skip to content

Commit

Permalink
add a test fips command
Browse files Browse the repository at this point in the history
  • Loading branch information
etnbrd committed Nov 15, 2024
1 parent f624731 commit e17fc48
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/commands/lambda/__tests__/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ export const makeCli = () => {
return cli
}

export const mockLambdaClientCommands = (lambdaClientMock: AwsStub<LServiceInputTypes, LServiceOutputTypes, any>) => {
export const mockLambdaClientCommands = (lambdaClientMock: AwsStub<LServiceInputTypes, LServiceOutputTypes>) => {

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 50 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).
lambdaClientMock.on(UpdateFunctionConfigurationCommand).resolves({})
lambdaClientMock.on(TagResourceCommand).resolves({})
lambdaClientMock.on(GetLayerVersionCommand).rejects()
lambdaClientMock.on(ListFunctionsCommand).resolves({Functions: []})
}

export const mockLambdaConfigurations = (
lambdaClientMock: AwsStub<LServiceInputTypes, LServiceOutputTypes, any>,
lambdaClientMock: AwsStub<LServiceInputTypes, LServiceOutputTypes>,

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 58 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).
functionConfigurations: Record<string, {config: LFunctionConfiguration; tags?: ListTagsResponse}>
) => {
const functions: LFunctionConfiguration[] = []
Expand Down Expand Up @@ -88,7 +88,7 @@ export const mockLambdaConfigurations = (
}

export const mockLambdaLayers = (
lambdaClientMock: AwsStub<LServiceInputTypes, LServiceOutputTypes, any>,
lambdaClientMock: AwsStub<LServiceInputTypes, LServiceOutputTypes>,

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 91 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).
layers: Record<string, GetLayerVersionCommandInput>
) => {
for (const layerName in layers) {
Expand All @@ -108,7 +108,7 @@ export const mockLambdaLayers = (
}

export const mockLogGroups = (
cloudWatchLogsClientMock: AwsStub<CWLServiceInputTypes, CWLServiceOutputTypes, any>,
cloudWatchLogsClientMock: AwsStub<CWLServiceInputTypes, CWLServiceOutputTypes>,

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 111 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).
logGroups: Record<
string,
{
Expand Down Expand Up @@ -136,7 +136,7 @@ export const mockLogGroups = (
}

export const mockCloudWatchLogsClientCommands = (
cloudWatchLogsClientMock: AwsStub<CWLServiceInputTypes, CWLServiceOutputTypes, any>
cloudWatchLogsClientMock: AwsStub<CWLServiceInputTypes, CWLServiceOutputTypes>

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 139 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).
) => {
cloudWatchLogsClientMock.on(DescribeLogGroupsCommand).resolves({})
cloudWatchLogsClientMock.on(DescribeSubscriptionFiltersCommand).resolves({})
Expand All @@ -146,21 +146,21 @@ export const mockCloudWatchLogsClientCommands = (
}

export const mockCloudWatchLogStreams = (
cloudWatchLogsClientMock: AwsStub<CWLServiceInputTypes, CWLServiceOutputTypes, any>,
cloudWatchLogsClientMock: AwsStub<CWLServiceInputTypes, CWLServiceOutputTypes>,

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 149 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).
logStreams: LogStream[]
) => {
cloudWatchLogsClientMock.on(DescribeLogStreamsCommand).resolves({logStreams})
}

export const mockCloudWatchLogEvents = (
cloudWatchLogsClientMock: AwsStub<CWLServiceInputTypes, CWLServiceOutputTypes, any>,
cloudWatchLogsClientMock: AwsStub<CWLServiceInputTypes, CWLServiceOutputTypes>,

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 156 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).
events: OutputLogEvent[]
) => {
cloudWatchLogsClientMock.on(GetLogEventsCommand).resolves({events})
}

export const mockResourceTags = (
lambdaClientMock: AwsStub<ServiceInputTypes, ServiceOutputTypes, any>,
lambdaClientMock: AwsStub<ServiceInputTypes, ServiceOutputTypes>,

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).

Check failure on line 163 in src/commands/lambda/__tests__/fixtures.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Generic type 'AwsStub<TInput, TOutput, TConfiguration>' requires 3 type argument(s).
output: ListTagsCommandOutput
) => {
lambdaClientMock.on(ListTagsCommand).resolves(output)
Expand Down
34 changes: 33 additions & 1 deletion src/commands/synthetics/__tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ test('all option flags are supported', async () => {
'failOnMissingTests',
'failOnTimeout',
'files',
'fips',
'fipsIgnoreError',
'jUnitReport',
'mobileApplicationVersion',
'mobileApplicationVersionFilePath',
Expand Down Expand Up @@ -62,6 +64,8 @@ describe('run-test', () => {
const overrideEnv = {
DATADOG_API_KEY: 'fake_api_key',
DATADOG_APP_KEY: 'fake_app_key',
DATADOG_FIPS: 'true',
DATADOG_FIPS_IGNORE_ERROR: 'true',
DATADOG_SITE: 'datadoghq.eu',
DATADOG_SUBDOMAIN: 'custom',
DATADOG_SYNTHETICS_BATCH_TIMEOUT: '1',
Expand Down Expand Up @@ -153,6 +157,8 @@ describe('run-test', () => {
failOnMissingTests: toBoolean(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS),
failOnTimeout: toBoolean(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT),
files: overrideEnv.DATADOG_SYNTHETICS_FILES.split(';'),
fipsEnabled: true,
fipsIgnoreError: true,
jUnitReport: overrideEnv.DATADOG_SYNTHETICS_JUNIT_REPORT,
publicIds: overrideEnv.DATADOG_SYNTHETICS_PUBLIC_IDS.split(';'),
selectiveRerun: toBoolean(overrideEnv.DATADOG_SYNTHETICS_SELECTIVE_RERUN),
Expand Down Expand Up @@ -223,6 +229,8 @@ describe('run-test', () => {
failOnMissingTests: true,
failOnTimeout: false,
files: ['my-new-file'],
fipsEnabled: true,
fipsIgnoreError: true,
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
global: {
allowInsecureCertificates: true,
Expand Down Expand Up @@ -288,6 +296,8 @@ describe('run-test', () => {
failOnMissingTests: true,
failOnTimeout: false,
files: ['new-file'],
fipsEnabled: true,
fipsIgnoreError: true,
jUnitReport: 'junit-report.xml',
mobileApplicationVersionFilePath: './path/to/application.apk',
pollingTimeout: 2,
Expand Down Expand Up @@ -345,6 +355,8 @@ describe('run-test', () => {
command['failOnMissingTests'] = overrideCLI.failOnMissingTests
command['failOnTimeout'] = overrideCLI.failOnTimeout
command['files'] = overrideCLI.files
command['fipsEnabled'] = overrideCLI.fipsEnabled
command['fipsIgnoreError'] = overrideCLI.fipsIgnoreError
command['jUnitReport'] = overrideCLI.jUnitReport
command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion
command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath
Expand Down Expand Up @@ -436,6 +448,8 @@ describe('run-test', () => {
failOnMissingTests: true,
failOnTimeout: false,
files: ['new-file'],
fipsEnabled: true,
fipsIgnoreError: true,
jUnitReport: 'junit-report.xml',
pollingTimeout: 2,
publicIds: ['ran-dom-id2'],
Expand Down Expand Up @@ -500,6 +514,8 @@ describe('run-test', () => {
failOnMissingTests: true,
failOnTimeout: false,
files: ['new-file'],
fipsEnabled: true,
fipsIgnoreError: true,
jUnitReport: 'junit-report.xml',
publicIds: ['ran-dom-id2'],
pollingTimeout: 1,
Expand Down Expand Up @@ -562,7 +578,7 @@ describe('run-test', () => {
//
// (config file < ENV < CLI < test file) => execute tests

describe('override precedence - config file < ENV < CLI < test file', () => {
describe('override precedence - [config file < ENV < CLI < test file]', () => {
const configFile = {
apiKey: 'config_file_api_key',
appKey: 'config_file_app_key',
Expand Down Expand Up @@ -598,6 +614,8 @@ describe('run-test', () => {
failOnMissingTests: false,
failOnTimeout: false,
files: ['from_config_file.json'],
fipsEnabled: false,
fipsIgnoreError: false,
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
global: {},
jUnitReport: 'junit-report-from-config-file.xml',
Expand All @@ -622,6 +640,8 @@ describe('run-test', () => {
const overrideEnv = {
DATADOG_API_KEY: 'env_api_key',
DATADOG_APP_KEY: 'env_app_key',
DATADOG_FIPS: 'true',
DATADOG_FIPS_IGNORE_ERROR: 'true',
DATADOG_SITE: 'us5.datadoghq.com',
DATADOG_SUBDOMAIN: 'subdomain_from_env',
DATADOG_SYNTHETICS_BATCH_TIMEOUT: '1',
Expand Down Expand Up @@ -714,6 +734,8 @@ describe('run-test', () => {
failOnMissingTests: toBoolean(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS),
failOnTimeout: toBoolean(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT),
files: overrideEnv.DATADOG_SYNTHETICS_FILES?.split(';'),
fipsEnabled: toBoolean(overrideEnv.DATADOG_FIPS),
fipsIgnoreError: toBoolean(overrideEnv.DATADOG_FIPS_IGNORE_ERROR),
jUnitReport: overrideEnv.DATADOG_SYNTHETICS_JUNIT_REPORT,
publicIds: overrideEnv.DATADOG_SYNTHETICS_PUBLIC_IDS?.split(';'),
selectiveRerun: toBoolean(overrideEnv.DATADOG_SYNTHETICS_SELECTIVE_RERUN),
Expand Down Expand Up @@ -754,6 +776,8 @@ describe('run-test', () => {
failOnMissingTests: true,
failOnTimeout: true,
files: ['new-file-from-cli'],
fipsEnabled: true,
fipsIgnoreError: true,
jUnitReport: 'junit-report-from-cli.xml',
mobileApplicationVersionFilePath: './path/to/application-from-cli.apk',
pollingTimeout: 10,
Expand Down Expand Up @@ -815,6 +839,8 @@ describe('run-test', () => {
command['failOnMissingTests'] = overrideCLI.failOnMissingTests
command['failOnTimeout'] = overrideCLI.failOnTimeout
command['files'] = overrideCLI.files
command['fipsEnabled'] = overrideCLI.fipsEnabled
command['fipsIgnoreError'] = overrideCLI.fipsIgnoreError
command['jUnitReport'] = overrideCLI.jUnitReport
command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion
command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath
Expand Down Expand Up @@ -881,6 +907,8 @@ describe('run-test', () => {
const overrideEnv = {
DATADOG_API_KEY: 'env_api_key',
DATADOG_APP_KEY: 'env_app_key',
DATADOG_FIPS: 'false',
DATADOG_FIPS_IGNORE_ERROR: 'false',
DATADOG_SITE: 'us5.datadoghq.com',
DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config_from_env.json',
DATADOG_SUBDOMAIN: 'subdomain_from_env',
Expand Down Expand Up @@ -932,6 +960,8 @@ describe('run-test', () => {
failOnMissingTests: false,
failOnTimeout: false,
files: ['file-from-cli-1;file-from-cli-2'],
fipsEnabled: true,
fipsIgnoreError: true,
jUnitReport: 'junit-report-from-cli.xml',
mobileApplicationVersionFilePath: './path/to/application-from-cli.apk',
pollingTimeout: 10,
Expand Down Expand Up @@ -995,6 +1025,8 @@ describe('run-test', () => {
command['failOnMissingTests'] = overrideCLI.failOnMissingTests
command['failOnTimeout'] = overrideCLI.failOnTimeout
command['files'] = overrideCLI.files
command['fipsEnabled'] = overrideCLI.fipsEnabled
command['fipsIgnoreError'] = overrideCLI.fipsIgnoreError
command['jUnitReport'] = overrideCLI.jUnitReport
command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion
command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"failOnMissingTests": true,
"failOnTimeout": false,
"files": ["my-new-file"],
"fipsEnabled": true,
"fipsIgnoreError": true,
"jUnitReport": "junit-report.xml",
"global": {
"allowInsecureCertificates": true,
Expand Down
2 changes: 2 additions & 0 deletions src/commands/synthetics/__tests__/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export const ciConfig: RunTestsCommandConfig = {
failOnMissingTests: false,
failOnTimeout: true,
files: [],
fipsEnabled: false,
fipsIgnoreError: false,
jUnitReport: '',
global: {},
defaultTestOverrides: {},
Expand Down
4 changes: 4 additions & 0 deletions src/commands/synthetics/__tests__/run-tests-lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ describe('run-test', () => {
failOnMissingTests: false,
failOnTimeout: true,
files: ['{,!(node_modules)/**/}*.synthetics.json'],
fipsEnabled: false,
fipsIgnoreError: false,
global: {}, // deprecated
locations: [], // deprecated
pollingTimeout: 2 * 60 * 1000,
Expand Down Expand Up @@ -90,6 +92,8 @@ describe('run-test', () => {
failOnMissingTests: false,
failOnTimeout: true,
files: ['{,!(node_modules)/**/}*.synthetics.json'],
fipsEnabled: false,
fipsIgnoreError: false,
// TODO SYNTH-12989: Clean up deprecated `global` and `locations`
global: {},
locations: [],
Expand Down
2 changes: 2 additions & 0 deletions src/commands/synthetics/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ export interface RunTestsCommandConfig extends SyntheticsCIConfig {
failOnMissingTests: boolean
failOnTimeout: boolean
files: string[]
fipsEnabled: boolean
fipsIgnoreError: boolean
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
/** @deprecated This property is deprecated, please use `defaultTestOverrides` instead. */
global?: UserConfigOverride
Expand Down
28 changes: 28 additions & 0 deletions src/commands/synthetics/run-tests-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Command, Option} from 'clipanion'
import deepExtend from 'deep-extend'
import terminalLink from 'terminal-link'

import {enableFips, UnsupportedFipsError} from '../../helpers/fips'

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 5 in src/commands/synthetics/run-tests-command.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Cannot find module '../../helpers/fips' or its corresponding type declarations.
import {removeUndefinedValues, resolveConfigFromFile} from '../../helpers/utils'
import * as validation from '../../helpers/validation'
import {isValidDatadogSite} from '../../helpers/validation'
Expand Down Expand Up @@ -47,6 +48,8 @@ export const DEFAULT_COMMAND_CONFIG: RunTestsCommandConfig = {
failOnMissingTests: false,
failOnTimeout: true,
files: [],
fipsEnabled: false,
fipsIgnoreError: false,
// TODO SYNTH-12989: Clean up deprecated `global` in favor of `defaultTestOverrides`
global: {},
jUnitReport: '',
Expand Down Expand Up @@ -133,6 +136,12 @@ export class RunTestsCommand extends Command {
private files = Option.Array('-f,--files', {
description: `Glob pattern to detect Synthetic test ${$2('configuration files')}}.`,
})
private fipsEnabled = Option.Boolean('--fips', {
description: 'Use a FIPS compliant crypto provider. Throws an error if no FIPS compliant crypto provider are available.',
})
private fipsIgnoreError = Option.Boolean('--fipsIgnoreError', {
description: `Prevent error when using the ${$1('--fips')} option.`,
})
private mobileApplicationVersion = Option.String('--mobileApplicationVersion', {
description: 'Override the default mobile application version to test a different version within Datadog.',
})
Expand Down Expand Up @@ -187,6 +196,21 @@ export class RunTestsCommand extends Command {
return 1
}

if (this.config.fipsEnabled) {
try {
const fipsEnabled = enableFips()
if (!fipsEnabled) {
this.reporter.error('FIPS could not be enabled. The command will continue without FIPS mode.\n')
}
} catch (error) {
if (error instanceof UnsupportedFipsError) {
this.reporter.error('FIPS mode is not supported. The command will continue without FIPS mode.\n')
}

return toExitCode(getExitReason(this.config, {error}))
}
}

if (this.config.jUnitReport) {
reporters.push(
new JUnitReporter({
Expand Down Expand Up @@ -277,6 +301,8 @@ export class RunTestsCommand extends Command {
failOnMissingTests: toBoolean(process.env.DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS),
failOnTimeout: toBoolean(process.env.DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT),
files: process.env.DATADOG_SYNTHETICS_FILES?.split(';'),
fipsEnabled: toBoolean(process.env.DATADOG_FIPS),
fipsIgnoreError: toBoolean(process.env.DATADOG_FIPS_IGNORE_ERROR),
jUnitReport: process.env.DATADOG_SYNTHETICS_JUNIT_REPORT,
publicIds: process.env.DATADOG_SYNTHETICS_PUBLIC_IDS?.split(';'),
selectiveRerun: toBoolean(process.env.DATADOG_SYNTHETICS_SELECTIVE_RERUN),
Expand Down Expand Up @@ -357,6 +383,8 @@ export class RunTestsCommand extends Command {
failOnMissingTests: this.failOnMissingTests,
failOnTimeout: this.failOnTimeout,
files: this.files,
fipsEnabled: this.fipsEnabled,
fipsIgnoreError: this.fipsIgnoreError,
jUnitReport: this.jUnitReport,
publicIds: this.publicIds,
selectiveRerun: this.selectiveRerun,
Expand Down
24 changes: 24 additions & 0 deletions src/commands/test-fips/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Command } from 'clipanion'

import { enableFips } from '../../helpers/fips'

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Build and test (18)

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Build and test (20)

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Build and test (14)

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM ubuntu

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Build and test (16)

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ubuntu

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in macOS

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in ARM macOS

Cannot find module '../../helpers/fips' or its corresponding type declarations.

Check failure on line 3 in src/commands/test-fips/cli.ts

View workflow job for this annotation

GitHub Actions / Test standalone binary in windows

Cannot find module '../../helpers/fips' or its corresponding type declarations.

class TestFipsCommand extends Command {
public static paths = [['test-fips']]

public static usage = Command.Usage({
description: 'Test fips compliance of datadog-ci.',
})

public async execute() {
try {
const fipsEnabled = enableFips()
this.context.stdout.write(`FIPS is ${fipsEnabled ? 'enabled' : 'disabled'} (${fipsEnabled})\n`)
} catch (error) {
this.context.stdout.write(error.message)
}

return 0
}
}

module.exports = [TestFipsCommand]
7 changes: 7 additions & 0 deletions standalone-e2e/standalone-binary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ describe('standalone binary', () => {
expect(binaryVersion.slice(1)).toEqual(version)
})
})
describe('test-fips', () => {
it('report when FIPS is unsupported', async () => {
const {stdout} = await execPromise(`${STANDALONE_BINARY_PATH} test-fips`)
const testFipsOutput = sanitizeOutput(stdout)
expect(testFipsOutput).toEqual('FIPS mode is not supported')
})
})
describe('dsyms', () => {
it('can be called', async () => {
const {stdout} = await execPromise(`${STANDALONE_BINARY_PATH} dsyms upload --help`)
Expand Down

0 comments on commit e17fc48

Please sign in to comment.