-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #690 from atsign-foundation/668-ensure-atkeys-file…
…-is-writeable-before-finalizing-pkam-apkam
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:at_onboarding_cli/src/cli/auth_cli.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
final baseDirPath = 'test/keys'; | ||
group('A group of tests to verify write permission of apkam file path', () { | ||
final dirPath = '$baseDirPath/@alice-apkam-keys.atKeys'; | ||
|
||
test( | ||
'A test to verify isWritable returns false if directory has read-only permissions', | ||
() async { | ||
final directory = Directory(dirPath); | ||
// Create the directory first to ensure it exists before calling isWritable. | ||
await directory.create(recursive: true); | ||
// Set permission to read only. | ||
await Process.run('chmod', ['444', baseDirPath]); | ||
expect(canCreateFile(File(dirPath)), false); | ||
}); | ||
|
||
test( | ||
'A test verify isWritable returns true if directory does not have a file already', | ||
() { | ||
expect(canCreateFile(File(dirPath)), true); | ||
}); | ||
}); | ||
|
||
tearDown(() async { | ||
// Set full permissions to delete the directory. | ||
await Process.run('chmod', ['777', baseDirPath]); | ||
Directory(baseDirPath).deleteSync(recursive: true); | ||
}); | ||
} |