Skip to content

Commit 630c442

Browse files
committed
test(config): cover transport certificate config
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 255a791 commit 630c442

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/Unit/Config/CertConfigTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ public function testStoresAllProperties(): void
2121
cnpj: '29842527000145',
2222
pfxPath: '/etc/nfse/certs/company.pfx',
2323
vaultPath: 'secret/nfse/29842527000145',
24+
transportCertificatePath: '/etc/nfse/certs/client.crt.pem',
25+
transportPrivateKeyPath: '/etc/nfse/certs/client.key.pem',
2426
);
2527

2628
self::assertSame('29842527000145', $config->cnpj);
2729
self::assertSame('/etc/nfse/certs/company.pfx', $config->pfxPath);
2830
self::assertSame('secret/nfse/29842527000145', $config->vaultPath);
31+
self::assertSame('/etc/nfse/certs/client.crt.pem', $config->transportCertificatePath);
32+
self::assertSame('/etc/nfse/certs/client.key.pem', $config->transportPrivateKeyPath);
2933
}
3034

3135
public function testCnpjIsReadonly(): void
@@ -66,4 +70,32 @@ public function testVaultPathIsReadonly(): void
6670
/** @phpstan-ignore-next-line */
6771
$config->vaultPath = 'other';
6872
}
73+
74+
public function testTransportCertificatePathIsReadonly(): void
75+
{
76+
$config = new CertConfig(
77+
cnpj: '29842527000145',
78+
pfxPath: '/etc/nfse/certs/company.pfx',
79+
vaultPath: 'secret/nfse/29842527000145',
80+
transportCertificatePath: '/etc/nfse/certs/client.crt.pem',
81+
);
82+
83+
$this->expectException(\Error::class);
84+
/** @phpstan-ignore-next-line */
85+
$config->transportCertificatePath = 'other';
86+
}
87+
88+
public function testTransportPrivateKeyPathIsReadonly(): void
89+
{
90+
$config = new CertConfig(
91+
cnpj: '29842527000145',
92+
pfxPath: '/etc/nfse/certs/company.pfx',
93+
vaultPath: 'secret/nfse/29842527000145',
94+
transportPrivateKeyPath: '/etc/nfse/certs/client.key.pem',
95+
);
96+
97+
$this->expectException(\Error::class);
98+
/** @phpstan-ignore-next-line */
99+
$config->transportPrivateKeyPath = 'other';
100+
}
69101
}

0 commit comments

Comments
 (0)