Skip to content

Commit

Permalink
migrate to 7.3/8.0, add tests
Browse files Browse the repository at this point in the history
* no composer.lock in libraries

* move to later versions of php for travis

* fix merge error

* add executable bit for tests

* clean up camelCase

* failing test was due to Process component behavior

* move to php7.3 && php8.0

* add lock file

* remove lock file

* add sshPipelining test
  • Loading branch information
maschmann authored May 9, 2021
1 parent d526011 commit 82d5673
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2,363 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ matrix:
include:
- php: 7.3
- php: 7.4
- php: 8.0

before_script:
- if [ "$PROCESS_VERSION" != "" ]; then composer require symfony/process:${PROCESS_VERSION} --dev --no-update; fi
Expand Down
3 changes: 2 additions & 1 deletion Asm/Ansible/Command/AnsiblePlaybook.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,13 @@ public function hostKeyChecking(bool $enable = true): AnsiblePlaybookInterface
$this->processBuilder->setEnv('ANSIBLE_HOST_KEY_CHECKING', $flag);
return $this;
}

/**
* Ansible SSH pipelining option
* https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-pipelining
*
* @param bool $enable
* @return AnsiblePlaybookInterface
**/
public function sshPipelining(bool $enable = false): AnsiblePlaybookInterface
{
Expand Down
9 changes: 9 additions & 0 deletions Asm/Ansible/Command/AnsiblePlaybookInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ public function sshCommonArgs($sshArgs): AnsiblePlaybookInterface;
*/
public function sshExtraArgs($extraArgs): AnsiblePlaybookInterface;

/**
* Ansible SSH pipelining option
* https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-pipelining
*
* @param bool $enable
* @return AnsiblePlaybookInterface
**/
public function sshPipelining(bool $enable = false): AnsiblePlaybookInterface;

/**
* Perform a syntax check on the playbook, but do not execute it.
*
Expand Down
47 changes: 40 additions & 7 deletions Tests/Asm/Ansible/Command/AnsiblePlaybookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Exception;
use InvalidArgumentException;
use Symfony\Component\Process\Process;
use TypeError;

class AnsiblePlaybookTest extends AnsibleTestCase
{
Expand Down Expand Up @@ -863,13 +864,17 @@ public function testExtraVars()

foreach ($tests as $input) {
try {
$ansible = new AnsiblePlaybook($builder);
$ansible->extraVars($input);

// We should never reach this line!
$this->fail(sprintf('Failing asserting that %s exception has been thrown', InvalidArgumentException::class));
}
catch (InvalidArgumentException $ignored) {
try {
$ansible = new AnsiblePlaybook($builder);
$ansible->extraVars($input);

// We should never reach this line!
$this->fail(sprintf('Failing asserting that %s exception has been thrown',
InvalidArgumentException::class));
} catch (InvalidArgumentException $ignored) {
}
} catch (TypeError $ignored) {
// not nice .. this is to keep a bit of BC, since php is more strict on argument types
}
}

Expand Down Expand Up @@ -991,4 +996,32 @@ public function testHostKeyChecking()
$this->assertEquals($expect, $env['ANSIBLE_HOST_KEY_CHECKING']);
}
}

public function testSshPipelining()
{
$tests = [
[
'input' => true,
'expect' => 'True',
],
[
'input' => false,
'expect' => 'False',
],
];

$builder = new ProcessBuilder($this->getPlaybookUri(), $this->getProjectUri());
foreach ($tests as $test) {

$input = $test['input'];
$expect = $test['expect'];

$ansible = new AnsiblePlaybook($builder);
$ansible->sshPipelining($input);
$env = $builder->getProcess()->getEnv();

$this->assertArrayHasKey('ANSIBLE_SSH_PIPELINING', $env);
$this->assertEquals($expect, $env['ANSIBLE_SSH_PIPELINING']);
}
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^7.1.0|>8.0.0",
"php": "^7.3.0|^8.0.0",
"psr/log": "^1.1",
"symfony/process": "^4.0|^5.0"
},
Expand Down
Loading

0 comments on commit 82d5673

Please sign in to comment.