Skip to content

Commit

Permalink
last adjusments
Browse files Browse the repository at this point in the history
  • Loading branch information
MadameSheema committed Nov 15, 2023
1 parent 7e2f4e0 commit 5a6e17d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
1 change: 0 additions & 1 deletion config/serverless.security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ xpack.securitySolutionServerless.productTypes:
[
{ product_line: 'security', product_tier: 'complete' },
{ product_line: 'endpoint', product_tier: 'complete' },
{ product_line: 'cloud', product_tier: 'complete'},
]

xpack.securitySolution.offeringSettings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface Project {
product: string;
}

interface ProjectConfigurationOverride {
interface ProjectConfigurationParameters {
tier: string;
ignoreEndpoint: boolean;
ignoreCloud: boolean;
Expand All @@ -59,6 +59,12 @@ interface Credentials {
password: string;
}

const DEFAULT_CONFIGURATION: ProductType[] = [
{ product_line: 'security', product_tier: 'complete' },
{ product_line: 'cloud', product_tier: 'complete' },
{ product_line: 'endpoint', product_tier: 'complete' },
] as const;

const DEFAULT_REGION = 'aws-eu-west-1';
const PROJECT_NAME_PREFIX = 'kibana-cypress-security-solution-ephemeral';
const BASE_ENV_URL = 'https://global.qa.cld.elstc.co';
Expand Down Expand Up @@ -326,21 +332,21 @@ function waitForKibanaLogin(kbUrl: string, credentials: Credentials): Promise<vo
return pRetry(fetchLoginStatusAttempt, retryOptions);
}

const getProductTypes = (
filePath: string,
projectConfigurationOverride: ProjectConfigurationOverride
const getOverridedProductTypes = (
projectConfigurationParameters: ProjectConfigurationParameters
): ProductType[] => {
let productTypes = parseTestFileConfig(filePath).productTypes as ProductType[];
if (projectConfigurationOverride.tier) {
let productTypes = DEFAULT_CONFIGURATION;

if (projectConfigurationParameters.tier) {
productTypes = productTypes.map((product) => ({
...product,
product_tier: projectConfigurationOverride.tier,
product_tier: projectConfigurationParameters.tier,
}));
}
if (projectConfigurationOverride.ignoreEndpoint) {
if (projectConfigurationParameters.ignoreEndpoint) {
productTypes = productTypes.filter((product) => product.product_line !== 'endpoint');
}
if (projectConfigurationOverride.ignoreCloud) {
if (projectConfigurationParameters.ignoreCloud) {
productTypes = productTypes.filter((product) => product.product_line !== 'cloud');
}
return productTypes;
Expand Down Expand Up @@ -409,10 +415,10 @@ ${JSON.stringify(argv, null, 2)}
const cypressConfigFilePath = require.resolve(`../../${argv.configFile}`) as string;
const cypressConfigFile = await import(cypressConfigFilePath);

const projectConfigurationOverride: ProjectConfigurationOverride = {
const projectConfigurationParameters: ProjectConfigurationParameters = {
tier: argv.tier as string,
ignoreEndpoint: argv.ignoreEndpoint as boolean,
ignoreCloud: argv.ignoreClous as boolean,
ignoreCloud: argv.ignoreCloud as boolean,
};

log.info(`
Expand Down Expand Up @@ -483,7 +489,10 @@ ${JSON.stringify(cypressConfigFile, null, 2)}
await withProcRunner(log, async (procs) => {
const id = crypto.randomBytes(8).toString('hex');
const PROJECT_NAME = `${PROJECT_NAME_PREFIX}-${id}`;
const productTypes = getProductTypes(filePath, projectConfigurationOverride);

const productTypes = isOpen
? getOverridedProductTypes(projectConfigurationParameters)
: (parseTestFileConfig(filePath).productTypes as ProductType[]);

if (!API_KEY) {
log.info('API KEY to create project could not be retrieved.');
Expand Down

0 comments on commit 5a6e17d

Please sign in to comment.