test(credentials): enable some of the previously disabled tests for Linux (#82)

This commit is contained in:
Aleksey Kulikov 2023-02-02 16:15:24 +03:00 committed by GitHub
parent ed67a4e307
commit 7c6060b02c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,32 +83,28 @@ void main() {
cloneDir.deleteSync(recursive: true); cloneDir.deleteSync(recursive: true);
}); });
test( test('clones repository with provided keypair', () {
testOn: '!linux', final cloneDir = Directory.systemTemp.createTempSync('clone');
'clones repository with provided keypair', final keypair = Keypair(
() { username: 'git',
final cloneDir = Directory.systemTemp.createTempSync('clone'); pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
final keypair = Keypair( privateKey: p.join('test', 'assets', 'keys', 'id_rsa'),
username: 'git', passPhrase: 'empty',
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'), );
privateKey: p.join('test', 'assets', 'keys', 'id_rsa'), final callbacks = Callbacks(credentials: keypair);
passPhrase: 'empty',
);
final callbacks = Callbacks(credentials: keypair);
final repo = Repository.clone( final repo = Repository.clone(
url: 'ssh://git@github.com/libgit2/TestGitRepository', url: 'ssh://git@github.com/libgit2/TestGitRepository',
localPath: cloneDir.path, localPath: cloneDir.path,
callbacks: callbacks, callbacks: callbacks,
); );
expect(repo.isEmpty, false); expect(repo.isEmpty, false);
if (Platform.isLinux || Platform.isMacOS) { if (Platform.isLinux || Platform.isMacOS) {
cloneDir.deleteSync(recursive: true); cloneDir.deleteSync(recursive: true);
} }
}, });
);
test('throws when no credentials is provided', () { test('throws when no credentials is provided', () {
final cloneDir = Directory.systemTemp.createTempSync('clone'); final cloneDir = Directory.systemTemp.createTempSync('clone');
@ -189,36 +185,32 @@ void main() {
cloneDir.deleteSync(recursive: true); cloneDir.deleteSync(recursive: true);
}); });
test( test('clones repository with provided keypair from memory', () {
testOn: '!linux', final cloneDir = Directory.systemTemp.createTempSync('clone');
'clones repository with provided keypair from memory', final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
() { .readAsStringSync();
final cloneDir = Directory.systemTemp.createTempSync('clone'); final privateKey =
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub')) File(p.join('test', 'assets', 'keys', 'id_rsa')).readAsStringSync();
.readAsStringSync(); final keypair = KeypairFromMemory(
final privateKey = username: 'git',
File(p.join('test', 'assets', 'keys', 'id_rsa')).readAsStringSync(); pubKey: pubKey,
final keypair = KeypairFromMemory( privateKey: privateKey,
username: 'git', passPhrase: 'empty',
pubKey: pubKey, );
privateKey: privateKey, final callbacks = Callbacks(credentials: keypair);
passPhrase: 'empty',
);
final callbacks = Callbacks(credentials: keypair);
final repo = Repository.clone( final repo = Repository.clone(
url: 'ssh://git@github.com/libgit2/TestGitRepository', url: 'ssh://git@github.com/libgit2/TestGitRepository',
localPath: cloneDir.path, localPath: cloneDir.path,
callbacks: callbacks, callbacks: callbacks,
); );
expect(repo.isEmpty, false); expect(repo.isEmpty, false);
if (Platform.isLinux || Platform.isMacOS) { if (Platform.isLinux || Platform.isMacOS) {
cloneDir.deleteSync(recursive: true); cloneDir.deleteSync(recursive: true);
} }
}, });
);
test('throws when provided keypair from memory is incorrect', () { test('throws when provided keypair from memory is incorrect', () {
final cloneDir = Directory.systemTemp.createTempSync('clone'); final cloneDir = Directory.systemTemp.createTempSync('clone');