Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Cabecinha84 committed Jan 14, 2025
1 parent 9a7ac9d commit 8b76740
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions ZelBack/src/services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -4883,14 +4883,14 @@ async function checkAppSecrets(appName, appComponentSpecs, appOwner, registratio
const results = await dbHelper.findInDatabase(database, globalAppsInformation, query, projection);
let foundSecretsWithSameAppName = false;
let foundSecretsWithDifferentAppName = false;
const appComponentSecrets = appComponentSpecs.secrets.replace(/\r?\n|\r/, '').replace(/\W/g, '');
const appComponentSecrets = appComponentSpecs.secrets.replace(/\s+\r?\n|\r/, '').replace(/\W/g, '');
log.info(`checkAppSecrets - appComponentSecrets: ${appComponentSecrets}`);
// eslint-disable-next-line no-restricted-syntax
for (const app of results) {
if (app.version >= 7 && app.nodes.length > 0) {
// eslint-disable-next-line no-restricted-syntax
for (const component of app.compose) {
if (component.secrets && component.secrets.replace(/\r?\n|\r/, '').replace(/\W/g, '') === appComponentSecrets) {
if (component.secrets && component.secrets.replace(/\s+\r?\n|\r/, '').replace(/\W/g, '') === appComponentSecrets) {
if (registration) {
throw new Error(`Provided component ${appComponentSpecs.name} secrets are not valid`);
} else if (app.name !== appName) {
Expand All @@ -4913,15 +4913,26 @@ async function checkAppSecrets(appName, appComponentSpecs, appOwner, registratio
for (const message of permanentAppMessage) {
// eslint-disable-next-line no-restricted-syntax
for (const component of message.appSpecifications.compose) {
log.info(`checkAppSecrets - component secret: ${component.secrets.replace(/\r?\n|\r/, '').replace(/\W/g, '')}`);
if (component.secrets
&& component.secrets.replace(/\r?\n|\r/, '').replace(/\W/g, '') === appComponentSecrets) {
log.info('checkAppSecrets - found same secret');
log.info(`checkAppSecrets - appOwner: ${appOwner}`);
log.info(`checkAppSecrets - appOwner: ${message.appSpecifications.owner}`);
if (message.appSpecifications.owner !== appOwner) {
throw new Error(`Provided component ${appComponentSpecs.name} secrets are not valid`);
log.info(`checkAppSecrets - component secret: ${component.secrets.replace(/\s+\r?\n|\r/, '').replace(/\W/g, '')}`);
if (component.secrets) {
const componentSecrets = component.secrets.replace(/\s+\r?\n|\r/, '').replace(/\W/g, '');
if (componentSecrets.length !== appComponentSecrets.length) {
log.info('checkAppSecrets - lengths are different');
}
for (let n = 0; n < componentSecrets.length; n += 1) {
if (componentSecrets[n] !== appComponentSecrets[n]) {
log.info(`checkAppSecrets - ${n} different: '${componentSecrets[n]}' !== '${appComponentSecrets[n]}'`);
}
}
if (componentSecrets === appComponentSecrets) {
log.info('checkAppSecrets - found same secret');
log.info(`checkAppSecrets - appOwner: ${appOwner}`);
log.info(`checkAppSecrets - appOwner: ${message.appSpecifications.owner}`);
if (message.appSpecifications.owner !== appOwner) {
throw new Error(`Provided component ${appComponentSpecs.name} secrets are not valid`);
}
}
break;
}
}
}
Expand Down

0 comments on commit 8b76740

Please sign in to comment.