chore: Fix JDBC driver issues caused by blob incompatibility
chore: Remove lob annotation from certificate entity chore: Rename commonName colum to reflect it being in the subject information chore: Add more verbose logging chore: Update test to yield actually usefull assertion errors fix: Delete all items in the repository before running test - This fixes an issue where non-deterministic test order would cause the #singleElement assertion to fail sometimes
This commit is contained in:
parent
de738b7311
commit
8d83cba2cd
4 changed files with 25 additions and 12 deletions
|
@ -7,6 +7,8 @@ import de.mlessmann.certassist.models.CertificateExtension;
|
|||
import de.mlessmann.certassist.models.CertificateType;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -20,9 +22,15 @@ class CertificateRepositoryTest {
|
|||
@Autowired
|
||||
private CertificateExtensionRepository extensionRepository;
|
||||
|
||||
@BeforeEach
|
||||
void cleanUp() {
|
||||
extensionRepository.deleteAll();
|
||||
repository.deleteAll();
|
||||
}
|
||||
|
||||
private Certificate getCertificate() {
|
||||
final Certificate certificate = new Certificate();
|
||||
certificate.setCommonName("test-cn");
|
||||
certificate.setSubjectCommonName("test-cn");
|
||||
certificate.setType(CertificateType.SIGNED_CERT);
|
||||
certificate.setRequestedKeyLength(1);
|
||||
certificate.setRequestedValidityDays(1);
|
||||
|
@ -37,7 +45,7 @@ class CertificateRepositoryTest {
|
|||
repository.save(certificate);
|
||||
|
||||
Certificate foundCertificate = repository.findById(certificate.getId()).orElseThrow();
|
||||
assertThat(foundCertificate.getCommonName()).isEqualTo("test-cn");
|
||||
assertThat(foundCertificate.getSubjectCommonName()).isEqualTo("test-cn");
|
||||
assertThat(foundCertificate.getType()).isEqualTo(CertificateType.SIGNED_CERT);
|
||||
}
|
||||
|
||||
|
@ -51,8 +59,10 @@ class CertificateRepositoryTest {
|
|||
repository.save(certificate);
|
||||
|
||||
assertThat(repository.findById(certificate.getId()).orElseThrow().getCertificateExtension()).hasSize(1);
|
||||
assertThat(extensionRepository.findAll())
|
||||
.singleElement()
|
||||
.satisfies(ce -> assertThat(ce.getValue()).isEqualTo("test-ext-value"));
|
||||
List<CertificateExtension> extensions = StreamSupport
|
||||
.stream(extensionRepository.findAll().spliterator(), false)
|
||||
.toList();
|
||||
assertThat(extensions).hasSize(1);
|
||||
assertThat(extensions).singleElement().satisfies(ce -> assertThat(ce.getValue()).isEqualTo("test-ext-value"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue