Merge branch 'master' of github.com:JoN1oP/namp2
This commit is contained in:
BIN
codecept.phar
Normal file
BIN
codecept.phar
Normal file
Binary file not shown.
23
lib/util/dkim.php
Normal file
23
lib/util/dkim.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace MailPoet\Util;
|
||||
class DKIM {
|
||||
|
||||
public static function generate_keys() {
|
||||
try {
|
||||
$certificate = openssl_pkey_new(array('private_bits' => 1024));
|
||||
|
||||
$keys = array('public' => '', 'private' => '');
|
||||
|
||||
// get private key
|
||||
openssl_pkey_export($certificate, $keys['private']);
|
||||
|
||||
// get public key
|
||||
$details = openssl_pkey_get_details($certificate);
|
||||
$keys['public'] = $details['key'];
|
||||
|
||||
return $keys;
|
||||
} catch(Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
44
tests/unit/DKIMCest.php
Normal file
44
tests/unit/DKIMCest.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
use \UnitTester;
|
||||
|
||||
class DKIMCest
|
||||
{
|
||||
|
||||
public function _before(UnitTester $I)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function _after(UnitTester $I)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function it_can_generate_keys(UnitTester $I) {
|
||||
$I->wantTo('generate public and private keys');
|
||||
|
||||
$keys = \MailPoet\Util\DKIM::generate_keys();
|
||||
|
||||
$I->expect('public key is not empty');
|
||||
$I->assertNotEmpty($keys['public']);
|
||||
|
||||
$I->expect('private key is not empty');
|
||||
$I->assertNotEmpty($keys['private']);
|
||||
|
||||
$I->expect('public key starts with proper header');
|
||||
$I->assertTrue(
|
||||
strpos(
|
||||
$keys['public'],
|
||||
'-----BEGIN PUBLIC KEY-----'
|
||||
) === 0
|
||||
);
|
||||
|
||||
$I->expect('private key starts with proper header');
|
||||
$I->assertTrue(
|
||||
strpos(
|
||||
$keys['private'],
|
||||
'-----BEGIN RSA PRIVATE KEY-----'
|
||||
) === 0
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user