forked from madeny/lhttps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakerTest.php
More file actions
114 lines (83 loc) · 2.73 KB
/
MakerTest.php
File metadata and controls
114 lines (83 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Madeny\lhttps\Domain;
use Madeny\lhttps\Path;
use Madeny\lhttps\Maker;
use Symfony\Component\Dotenv\Dotenv;
class MakerTest extends TestCase
{
public function setUp()
{
$this->path = Path::all();
$this->domain = new domain;
$this->domain->setDomainOne('madeny.me');
}
/** @test */
public function a_user_can_generate_root_certificate_key()
{
$rootkey = file_exists($this->path.'/keys/root.key');
if ($rootkey) {
echo "\n You already have a Root Key I'm using that! \n";
}else{
$keygen = Maker::keygen($this->path);
if ($keygen->getError() == 0) {
echo "\n Key created with success \n";
}else{
echo "Something not right";
}
$rootkey = true;
}
$this->assertEquals($rootkey, true);
}
/** @test */
public function a_user_can_create_root_certificate_authority()
{
if (file_exists($this->path.'/csr/root.pem')) {
echo "\n You already have a Root Certificate we can use that!";
}else{
$ca = Maker::create($this->path);
if ($ca->getError() == 0) {
echo "\n Certificate create success \n";
}else{
echo "\n Sorry something is wrong \n";
}
}
$rootCA = file_exists($this->path.'/csr/root.pem');
$this->assertEquals($rootCA, true);
}
/** @test */
public function a_user_can_create_certificate_key_for_domain()
{
$domainkey = file_exists($this->path.'/live/'.$this->domain->getDomainOne().'.ssl.key');
$domaincsr = file_exists($this->path.'/csr/'.$this->domain->getDomainOne().'.csr');
if ($domainkey) {
echo "\n You already have a key for this domain we can sign this \n";
}else{
Maker::domain($this->path, $this->domain->getDomainOne(), $this->domain->getDomainTwo());
$domainkey = true;
$domaincsr = true;
}
$this->assertEquals($domainkey, true);
$this->assertEquals($domaincsr, true);
}
/** @test */
public function a_user_can_sign_a_domain_cert_with_root_certificate_authority()
{
$request = Maker::request($this->path, $this->domain->getDomainOne());
$process = file_get_contents(realpath($this->path.'/csr/process'));
// die(var_dump(exec("cat {$process}")));
if (strpos($process, "values mismatch") == true){
echo "\n Please delete your your CA and CAkey and make new one \n";
$request->setError(0);
}
$this->assertEquals($request->getError(), 0);
}
/** @test */
public function a_user_can_Trust_the_root_SSL_certificate()
{
$os = exec("uname -a");
$trusted = Maker::trust($this->path, $os, $option = null);
$this->assertEquals($trusted->getError(), 2);
}
}