Skip to content

Commit

Permalink
Merge pull request #16 from exonet/rja/fix-plain-to-plain
Browse files Browse the repository at this point in the history
Set the crt, key and bundle fields using setPlain
  • Loading branch information
robbinjanssen committed May 27, 2022
2 parents 323dab2 + cdbb195 commit 896ec60
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Formats/Plain.php
Expand Up @@ -53,6 +53,18 @@ public function getPlain(): self
return $this;
}

/**
* {@inheritdoc}
*/
public function setPlain(Plain $plain): FormatInterface
{
$this->crt = $plain->getCrt();
$this->key = $plain->getKey();
$this->caBundle = $plain->getCaBundle();

return $this;
}

/**
* Get the crt.
*
Expand Down
17 changes: 17 additions & 0 deletions tests/ConverterTest.php
Expand Up @@ -68,4 +68,21 @@ public function testPlainToPemZip()

unlink(__DIR__.'/example.com.zip');
}

public function testPlainToPlainString()
{
$plain = (new Plain())
->setCrt(TestCertificate::CRT)
->setKey(TestCertificate::KEY)
->setCaBundle(TestCertificate::CA_BUNDLE);

$converter = (new Converter())
->from($plain)
->to(new Plain());

$this->assertSame(
TestCertificate::CRT.TestCertificate::KEY.TestCertificate::CA_BUNDLE,
$converter->asString()
);
}
}

0 comments on commit 896ec60

Please sign in to comment.