From 5273c4cea366975615fa52c979f0634582fd6766 Mon Sep 17 00:00:00 2001 From: Didier Belot Date: Thu, 2 Apr 2015 09:27:18 +0200 Subject: [PATCH 1/2] Allowing no password option if privateKey is set --- src/Adapter/Factory/SftpAdapterFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adapter/Factory/SftpAdapterFactory.php b/src/Adapter/Factory/SftpAdapterFactory.php index e30be6d..5f04d32 100644 --- a/src/Adapter/Factory/SftpAdapterFactory.php +++ b/src/Adapter/Factory/SftpAdapterFactory.php @@ -44,8 +44,8 @@ protected function validateConfig() throw new UnexpectedValueException("Missing 'username' as option"); } - if (!isset($this->options['password'])) { - throw new UnexpectedValueException("Missing 'password' as option"); + if (!isset($this->options['password']) && !isset($this->options['privateKey'])) { + throw new UnexpectedValueException("Missing either 'password' or 'privateKey' as option"); } } } From 518508649aae7fc2061c86bac9dee48df935f230 Mon Sep 17 00:00:00 2001 From: Didier Belot Date: Thu, 2 Apr 2015 09:49:19 +0200 Subject: [PATCH 2/2] sftp options, adjusting tests --- test/Adapter/Factory/SftpAdapterFactoryTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Adapter/Factory/SftpAdapterFactoryTest.php b/test/Adapter/Factory/SftpAdapterFactoryTest.php index a416d1d..c1c353c 100644 --- a/test/Adapter/Factory/SftpAdapterFactoryTest.php +++ b/test/Adapter/Factory/SftpAdapterFactoryTest.php @@ -90,12 +90,16 @@ public function validateConfigProvider() ['host' => 'foo', 'port' => 'foo', 'username' => 'foo'], false, 'UnexpectedValueException', - "Missing 'password' as option" + "Missing either 'password' or 'privateKey' as option" ], [ ['host' => 'foo', 'port' => 'foo', 'username' => 'foo', 'password' => 'foo'], ['host' => 'foo', 'port' => 'foo', 'username' => 'foo', 'password' => 'foo'], ], + [ + ['host' => 'foo', 'port' => 'foo', 'username' => 'foo', 'privateKey' => 'foo'], + ['host' => 'foo', 'port' => 'foo', 'username' => 'foo', 'privateKey' => 'foo'], + ], ]; } }