Skip to content
Snippets Groups Projects
Commit 815c4b23 authored by sandcha's avatar sandcha
Browse files

Introduce BUDGET_OAUTH2_JWT_TEST_TOKEN env var

To set a token for tests requesting calculations from Web API
parent 70d7eff9
No related branches found
No related tags found
No related merge requests found
Pipeline #6670 passed
......@@ -21,10 +21,11 @@ GITHUB_PERSONAL_ACCESS_TOKEN=null
OAUTH2_ACCESS_TOKEN_URL="https://IDENTITY_PROVIDER/REALM/token"
OAUTH2_AUTHORIZATION_URL="https://IDENTITY_PROVIDER/REALM/auth"
OAUTH2_PROFILE_URL="https://IDENTITY_PROVIDER/REALM/userinfo"
# different values for developement and production modes
# set different values for developement and production modes
OAUTH2_CLIENT_ID="OAUTH2_CLIENT_ID"
OAUTH2_CLIENT_SECRET="OAUTH2_CLIENT_SECRET"
OAUTH2_JWT_SECRET="OAUTH2_JWT_SECRET"
BUDGET_OAUTH2_JWT_TEST_TOKEN="OAUTH2_JWT_TEST_TOKEN__GET_FROM_INTEGRATION_RESPONSE"
# Description of OpenFisca country repository (for edition / contribution)
OPENFISCA_BRANCH="harmonisation_ui_emmanuel"
......
......@@ -24,6 +24,7 @@ declare namespace App {
apiBudgetEndpointName: string
calculationBaseYear: number
calculationPlfYear: number
jwtTestToken?: string
}
openfiscaRepository: SessionOpenFiscaRepository
portalUrl: string
......
......@@ -74,7 +74,7 @@ test("calculateBudget", () => {
"https://api-simu-etat-integ.leximpact.dev/state_simulation"
const YEAR_BASE = "2022"
const YEAR_PLF = ""
const UNKNOWN_USER = config.oauth2.jwtSecret
const TOKEN_TEST_USER = config.budget.jwtTestToken
const AMENDEMENT_EXAMPLE = {
// AmendementRequest
"prelevements_sociaux.contributions_sociales.csg.activite.imposable.taux": 0.064,
......@@ -149,7 +149,7 @@ test("calculateBudget", () => {
calculateBudget(
fetch,
API_ENDPOINT_URL,
UNKNOWN_USER,
TOKEN_TEST_USER,
YEAR_BASE,
YEAR_PLF,
AMENDEMENT_EXAMPLE_2,
......
......@@ -198,8 +198,8 @@ export function auditOpenFiscaRepository(
true,
errors,
remainingKeys,
auditString,
auditTrimString,
auditRequire,
)
}
for (const key of ["rawUrlTemplate", "urlTemplate"]) {
......@@ -261,6 +261,16 @@ function auditBudget(audit: Audit, dataUnknown: unknown): [unknown, unknown] {
)
}
audit.attribute(
data,
"jwtTestToken",
true,
errors,
remainingKeys,
auditString,
auditTrimString,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
......
......@@ -12,7 +12,6 @@ const API_OUTPUT_VARIABLES: string[] = [
"assiette_csg_abattue",
"assiette_csg_non_abattue",
"csg_imposable_salaire",
"csg_deductible_salaire",
]
const API_QUANTILES_BASE_VARIABLES: string[] = [
......
......@@ -17,6 +17,7 @@ export interface Config {
clientId: string
clientSecret: string
jwtSecret: string
jwtTestToken: string
profileUrl: string
}
openfiscaRepository: {
......@@ -36,6 +37,7 @@ export interface Config {
apiBudgetEndpointName: string
calculationBaseYear: number
calculationPlfYear: number
jwtTestToken?: string
}
}
......@@ -79,6 +81,7 @@ const [validConfig, error] = validateConfig({
apiBudgetEndpointName: process.env["API_BUDGET_ENDPOINT_NAME"],
calculationBaseYear: process.env["CALCULATION_BASE_YEAR"],
calculationPlfYear: process.env["CALCULATION_PLF_YEAR"],
jwtTestToken: process.env["BUDGET_OAUTH2_JWT_TEST_TOKEN"],
}
: null,
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment