Replaced urlencdoded by json, improved doc + tests
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"description": "Create a Tenant",
"requestBody": {
"content": {
- "application/x-www-form-urlencoded": {
+ "application/json": {
"schema": {
"$ref": "#/components/schemas/Tenant"
}
"description": "Sign in",
"requestBody": {
"content": {
- "application/x-www-form-urlencoded": {
+ "application/json": {
"schema": {
"type": "object",
"required": [
"description": "Register",
"requestBody": {
"content": {
- "application/x-www-form-urlencoded": {
+ "application/json": {
"schema": {
"type": "object",
"required": [
"description": "Reset password",
"requestBody": {
"content": {
- "application/x-www-form-urlencoded": {
+ "application/json": {
"schema": {
"type": "object",
"required": ["email", "tenant"],
"type": "string",
"example": "03AGdBq26Ca8rdqn0-odDV18kJCLnVytzGPXVPyW811IY4pqyQuak-o59MZlYfUIVS-ToLBiL4o7fBfPPvmkAhQLKoMXtqitKxRTG016wmGbFLvZWnOSkJKreB1Kx6n3dB7uYd302UVyVpJJ0BGFcmXWnWZmGnR3ZJC8IE1r7oVohcYVLttnKXtuhJwg5IdHe0HleYzOjxCBw9FnCJhVoSmaPn6FeVjWC9d8vSDwBq-18dA_cm6CQb7BhZm6LXWhMdW1_e_5DcSs1koj_vn3FGB7UQESsPp81WBfr6msCNiddNc1D4MRfF4wXeimJ1wplqoGOmMmI2Y_i-120grLrjkfzBNgDPQPWvfpUjeyW1f_T-5SaObYpUFEEZ4YW6Xt2revAWMmZ6i9_QOWWUcukaZU3jr_MzR1YIMscKrnBP3Zhl45zLXOY-0Bi28z6XxsMqqSHE8lY_C8B-7M-X3PNc_293qtrEnE2rhG9PU-RdFJG4dqBcwU6YfZJwwyXDWG7eyNG8iJoBDgCWrbib2jLKTmuwWCowApAoeA"
},
- "hash": {
- "type": "string"
- },
"tenant": {
"type": "string",
"example": "slf"
}
}
+ },
+ "examples": {
+ "resetRequest": {
+ "summary": "Request a password reset",
+ "value": {
+ "email": "demo.demo@sap.com",
+ "captcha": "03AGdBq26Ca8rdqn0-odDV18kJCLnVytzGPXVPyW811IY4pqyQuak-o59MZlYfUIVS-ToLBiL4o7fBfPPvmkAhQLKoMXtqitKxRTG016wmGbFLvZWnOSkJKreB1Kx6n3dB7uYd302UVyVpJJ0BGFcmXWnWZmGnR3ZJC8IE1r7oVohcYVLttnKXtuhJwg5IdHe0HleYzOjxCBw9FnCJhVoSmaPn6FeVjWC9d8vSDwBq-18dA_cm6CQb7BhZm6LXWhMdW1_e_5DcSs1koj_vn3FGB7UQESsPp81WBfr6msCNiddNc1D4MRfF4wXeimJ1wplqoGOmMmI2Y_i-120grLrjkfzBNgDPQPWvfpUjeyW1f_T-5SaObYpUFEEZ4YW6Xt2revAWMmZ6i9_QOWWUcukaZU3jr_MzR1YIMscKrnBP3Zhl45zLXOY-0Bi28z6XxsMqqSHE8lY_C8B-7M-X3PNc_293qtrEnE2rhG9PU-RdFJG4dqBcwU6YfZJwwyXDWG7eyNG8iJoBDgCWrbib2jLKTmuwWCowApAoeA",
+ "tenant": "slf"
+ }
+ },
+ "resetValidation": {
+ "summary": "Validate password reset",
+ "value": {
+ "email": "demo.demo@sap.com",
+ "hash": "dcff1ec7-cecb-4c2f-99da-47aeb1f83509",
+ "tenant": "slf"
+ }
+ }
}
}
}
"description": "Get tenant EULA",
"parameters": [
{
- "in": "header",
+ "in": "query",
"name": "Tenant",
"description": "Tenant's subdomain",
"required": true,
},
{
"in": "query",
- "name": "language",
+ "name": "Language",
"description": "Browser language",
"schema": {
"type": "string",
"description": "Resend a verification email",
"requestBody": {
"content": {
- "application/x-www-form-urlencoded": {
+ "application/json": {
"schema": {
"type": "object",
"required": ["email", "tenant", "captcha"],

MODIFY
src/assets/server/rest/v1/schemas/auth/auth-eula.json
src/assets/server/rest/v1/schemas/auth/auth-eula.json
"Language": {
"$ref": "common.json#/definitions/language"
},
- "tenant": {
+ "Tenant": {
"$ref": "common.json#/definitions/subdomain"
}
}

MODIFY
src/assets/server/rest/v1/schemas/auth/auth-reset-password.json
src/assets/server/rest/v1/schemas/auth/auth-reset-password.json
}
},
"required": [
- "email",
- "captcha"
+ "email"
],
"anyOf": [
{ "required": ["captcha"] },

MODIFY
src/server/rest/v1/service/AuthService.ts
src/server/rest/v1/service/AuthService.ts
@@ -557,7 +557,7 @@ export default class AuthService {
public static async handleGetEndUserLicenseAgreement(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = AuthValidator.getInstance().validateAuthEula({ ...req.query, ...req.headers });
+ const filteredRequest = AuthValidator.getInstance().validateAuthEula(req.query);
// Get Tenant
const tenantID = await AuthService.getTenantID(filteredRequest.tenant);
if (!tenantID) {

MODIFY
test/api/AuthenticationTest.ts
test/api/AuthenticationTest.ts
@@ -146,6 +146,13 @@ describe('Authentication Service (tenant utall)', function() {
expect(response.data).to.have.property('status', 'Success');
});
+ it('Should be possible to retrieve tenant EULA', async () => {
+ const response = await CentralServerService.defaultInstance.authenticationApi.getTenantEula('');
+ // Check
+ expect(response.status).to.be.eql(200);
+ expect(response.data).to.have.property('text');
+ });
+
// pragma it('Should be logged off when the locale is updated', async () => {
// const newUser = await CentralServerService.defaultInstance.createEntity(
// CentralServerService.defaultInstance.userApi, UserFactory.build());

MODIFY
test/api/client/AuthenticationApi.ts
test/api/client/AuthenticationApi.ts
@@ -105,5 +105,19 @@ export default class AuthenticationApi {
});
return response;
}
+
+ public async getTenantEula(tenant = '', language?: string) {
+ const data = { tenant, language };
+ // Send
+ const response = await this._baseApi.send({
+ method: 'GET',
+ url: '/v1/auth/' + ServerAction.REST_END_USER_LICENSE_AGREEMENT,
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ data: data
+ });
+ return response;
+ }
}

Replaced urlencdoded by json, improved doc + tests