Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export async function runPostGenerationTasks(
// No need to await, we cannot recover anyway
// eslint-disable-next-line @typescript-eslint/no-floating-promises
storeService.write(service.backendSystem);
} else if (service.backendSystem?.newOrUpdated === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this condition should be inside (service.backendSystem && hostEnv !== hostEnvironment.bas) otherwise it will always log, even on bas.

logger.info(t('logMessages.noCredentialsBackendSystem', { system: service.backendSystem.name }));
}

// Display info message if using a cap service as it is not otherwise shown when a top level dir is not created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"warningCachingNotSupported": "Warning: caching is not supported.",
"attemptingToExecutePostGenerationCommand": "Attempting to execute command after app generation: {{- command}}",
"installSkippedOptionSpecified": "Option `--skipInstall` was specified. Installation of dependencies will be skipped.",
"generatorExiting": "Application generation exiting due to error: {{error}}"
"generatorExiting": "Application generation exiting due to error: {{error}}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"generatorExiting": "Application generation exiting due to error: {{error}}",
"generatorExiting": "Application generation was cancelled due to the error: {{error}}.",

"noCredentialsBackendSystem": "No credentials found for backend system: {{system}}. Skipping storing credentials."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"noCredentialsBackendSystem": "No credentials found for backend system: {{system}}. Skipping storing credentials."
"noCredentialsBackendSystem": "No credentials were found for the back-end system: {{system}}. Skipping storing credentials."

},
"error": {
"fatalError": "An error has occurred, please restart the generator.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ describe('runPostGenerationTasks', () => {
expect(storeServiceWriteMock).toHaveBeenCalledWith(service.backendSystem);
});

it('should NOT persist backend system when newOrUpdated is false', async () => {
const service = {
backendSystem: {
newOrUpdated: false
} as unknown as BackendSystem,
sapClient: '100',
odataVersion: OdataVersion.v2,
datasourceType: DatasourceType.sapSystem
};
const project = {
targetFolder: '/path/to/project',
name: 'testProject',
flpAppId: 'testAppId'
};

(getHostEnvironment as jest.Mock).mockReturnValue(hostEnvironment.vscode);

await runPostGenerationTasks({ service, project }, fs, logger, vscode, appWizard);

// Should not call getService or write when newOrUpdated is false
expect(getService).not.toHaveBeenCalled();
expect(storeServiceWriteMock).not.toHaveBeenCalled();
});

it('should show information message for cap projects', async () => {
const service = {
capService: {} as unknown as CapService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ export function getCredentialsPrompts<T extends Answers>(
severity: Severity.warning
};
}
// Only show password store warning if the system has stored credentials or if credentials are being newly saved
else if (PromptState.odataService.connectedSystem?.backendSystem?.newOrUpdated) {
return {
message: t('texts.passwordStoreWarning'),
severity: Severity.information
};
}
}
} as PasswordQuestion<T>
];
Expand All @@ -150,13 +157,14 @@ function updatePromptStateWithConnectedSystem(
// Update the existing backend system with the new credentials that may be used to update in the store.
if (selectedSystem?.type === 'backendSystem') {
const backendSystem = selectedSystem.system as BackendSystem;

// Have the credentials changed..
if (backendSystem.username !== username || backendSystem.password !== password) {
PromptState.odataService.connectedSystem.backendSystem = Object.assign(backendSystem, {
username: username,
password,
userDisplayName: username,
newOrUpdated: true
newOrUpdated: backendSystem.username || backendSystem.password ? true : false
} as Partial<BackendSystem>);
}
// If the connection is successful and a destination was selected, assign the connected destination to the prompt state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,35 @@ export async function getSystemConnectionQuestions(
);
},
additionalMessages: async (selectedSystem: SystemSelectionAnswerType) => {
// Backend systems credentials may need to be updated
let message;
// Check for stored credentials or authentication failure message if a backend system is selected
if (
selectedSystem.type === 'backendSystem' &&
connectionValidator.systemAuthType === 'basic' &&
(await connectionValidator.isAuthRequired())
) {
return {
message: t('prompts.systemSelection.authenticationFailedUpdateCredentials'),
severity: Severity.information
};
const backend = selectedSystem.system as BackendSystem;
const missingCredentials = !backend.username || !backend.password;

if (missingCredentials) {
message = {
message: t('prompts.systemSelection.noStoredCredentials'),
severity: Severity.information
};
} else {
message = {
message: t('prompts.systemSelection.authenticationFailedUpdateCredentials'),
severity: Severity.information
};
}
}
if (connectionValidator.ignoreCertError) {
return {
message = {
message: t('warnings.certErrorIgnoredByNodeSetting'),
severity: Severity.warning
};
}
return message ? message : undefined;
}
} as ListQuestion<SystemSelectionAnswers>
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"newSystemChoiceLabel": "New System",
"hint": "Select a system configuration.",
"message": "System",
"authenticationFailedUpdateCredentials": "Authentication failed. Please try updating the credentials."
"authenticationFailedUpdateCredentials": "Authentication failed. Please try updating the credentials.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"authenticationFailedUpdateCredentials": "Authentication failed. Please try updating the credentials.",
"authenticationFailedUpdateCredentials": "Authentication failed. Check your credentials are correct and try again.",

"noStoredCredentials": "This stored system has no credentials. Please provide them. They will not be saved with system details."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"noStoredCredentials": "This stored system has no credentials. Please provide them. They will not be saved with system details."
"noStoredCredentials": "This stored system has no credentials. Please provide them. They will not be saved with the system details."

},
"abapOnBTPType": {
"message": "ABAP environment definition source",
Expand Down Expand Up @@ -256,6 +257,7 @@
"systemTypeS4HC": "S4HC",
"httpStatus": "HTTP Status {{httpStatus}}",
"checkDestinationAuthConfig": "Please check the SAP BTP destination authentication configuration.",
"choiceNameNone": "None"
"choiceNameNone": "None",
"passwordStoreWarning": "Passwords are stored in the OS credential manager and protected by its security policies."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"passwordStoreWarning": "Passwords are stored in the OS credential manager and protected by its security policies."
"passwordStoreWarning": "Passwords are stored in your operating system's credential manager and are protected by its security policies."

}
}
Loading