Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/LEAP-850-fix-credentials-file-pe…
Browse files Browse the repository at this point in the history
…rmissions' into approval-temp
  • Loading branch information
rick-rtt committed Sep 12, 2023
2 parents 1be099b + 6e5dae6 commit 032ed99
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions packages/core/src/services/file-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ describe("File Service", () => {
expect(nativeService.fs.writeFileSync).toHaveBeenNthCalledWith(1, newPath, data);
});

test("writeFileSyncWithOptions", () => {
const data = "fake-content";
const newPath = "new-path";
const options = { mode: "600" };
const fileService = new FileService(nativeService);
fileService.writeFileSyncWithOptions(newPath, data, options);
expect(nativeService.fs.writeFileSync).toHaveBeenCalledWith(newPath, data, options);
});

test("removeFileSync, if file exists", () => {
const path = "path";
const fileService = new FileService(nativeService);
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/services/file-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export class FileService {
return this.nativeService.fs.writeFileSync(filePath, content);
}

writeFileSyncWithOptions(filePath: string, content: string, options: any): any {
return this.nativeService.fs.writeFileSync(filePath, content, options);
}

/**
* Remove a file in a synchronous way
*
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ export class AppComponent implements OnInit {

if (check) {
this.fileService.renameSync(oldAwsCredentialsPath, newAwsCredentialsPath);
this.fileService.writeFileSync(oldAwsCredentialsPath, "");
this.fileService.writeFileSyncWithOptions(oldAwsCredentialsPath, "", { mode: "600" });
this.appService.getDialog().showMessageBox({
type: "info",
icon: __dirname + "/assets/images/Leapp.png",
// eslint-disable-next-line max-len
message: "You had a previous credential file. We made a backup of the old one in the same directory before starting.",
});
} else if (!this.fileService.existsSync(this.awsCoreService.awsCredentialPath())) {
this.fileService.writeFileSync(this.awsCoreService.awsCredentialPath(), "");
this.fileService.writeFileSyncWithOptions(this.awsCoreService.awsCredentialPath(), "", { mode: "600" });
}
}

Expand Down

0 comments on commit 032ed99

Please sign in to comment.