Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security] Moved reset_creds call to reset_internal_creds #176410

Merged
merged 8 commits into from
Feb 13, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ KB_URL=$(echo $ENVIRONMENT_DETAILS | jq -r '.endpoints.kibana')
sleep 5

# Resetting the credentials of the elastic user in the project
CREDS_BODY=$(curl -s --location --request POST "$QA_CONSOLE_URL/api/v1/serverless/projects/security/$ID/_reset-credentials" \
CREDS_BODY=$(curl -s --location --request POST "$QA_CONSOLE_URL/api/v1/serverless/projects/security/$ID/_reset-internal-credentials" \
--header "Authorization: ApiKey $QA_API_KEY" \
--header 'Content-Type: application/json' | jq '.')
USERNAME=$(echo $CREDS_BODY | jq -r '.username')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async function resetCredentials(

const fetchResetCredentialsStatusAttempt = async (attemptNum: number) => {
const response = await axios.post(
`${BASE_ENV_URL}/api/v1/serverless/projects/security/${projectId}/_reset-credentials`,
`${BASE_ENV_URL}/api/v1/serverless/projects/security/${projectId}/_reset-internal-credentials`,
{},
{
headers: {
Expand All @@ -199,7 +199,7 @@ async function resetCredentials(
if (error instanceof AxiosError && error.code === 'ENOTFOUND') {
log.info('Project is not reachable. A retry will be triggered soon..');
} else {
log.info(error);
log.error(`${error.message}`);
}
},
retries: 100,
Expand All @@ -223,6 +223,7 @@ function waitForProjectInitialized(projectId: string, apiKey: string): Promise<v
}
);
if (response.data.phase !== 'initialized') {
log.info(response.data);
throw new Error('Project is not initialized. A retry will be triggered soon...');
} else {
log.info('Project is initialized');
Expand All @@ -233,7 +234,7 @@ function waitForProjectInitialized(projectId: string, apiKey: string): Promise<v
if (error instanceof AxiosError && error.code === 'ENOTFOUND') {
log.info('Project is not reachable. A retry will be triggered soon...');
} else {
log.info(error);
log.error(`${error.message}`);
}
},
retries: 100,
Expand Down Expand Up @@ -294,7 +295,7 @@ function waitForKibanaAvailable(kbUrl: string, auth: string, runnerId: string):
`${runnerId}: The Kibana URL is not yet reachable. A retry will be triggered soon...`
);
} else {
log.info(`${runnerId}: ${error}`);
log.info(`${runnerId}: ${error.message}`);
}
},
retries: 50,
Expand Down Expand Up @@ -350,7 +351,7 @@ function waitForKibanaLogin(kbUrl: string, credentials: Credentials): Promise<vo
if (error instanceof AxiosError && error.code === 'ENOTFOUND') {
log.info('Project is not reachable. A retry will be triggered soon...');
} else {
log.info(error);
log.error(`${error.message}`);
}
},
retries: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const esArchiver = (
const isCloudServerless = config.env.CLOUD_SERVERLESS;

const serverlessCloudUser = {
username: 'elastic',
username: config.env.ELASTICSEARCH_USERNAME,
password: config.env.ELASTICSEARCH_PASSWORD,
};

Expand Down