From 909afc29f1978b05b067e4f9feffaaabe55643b9 Mon Sep 17 00:00:00 2001 From: Michael Simon <simon@kit.edu> Date: Thu, 13 Mar 2025 12:20:11 +0100 Subject: [PATCH] NO_STORY remove some referenced to non existing tests --- bwreg-service/pom.xml | 11 -- .../service/impl/RegistryServiceImplTest.java | 156 ------------------ .../service/ssh/SshPubKeyServiceTest.java | 134 --------------- regapp-jpa-impl/pom.xml | 6 - 4 files changed, 307 deletions(-) delete mode 100644 bwreg-service/src/test/java/edu/kit/scc/webreg/service/impl/RegistryServiceImplTest.java delete mode 100644 bwreg-service/src/test/java/edu/kit/scc/webreg/service/ssh/SshPubKeyServiceTest.java diff --git a/bwreg-service/pom.xml b/bwreg-service/pom.xml index 47faf11e8..b83fb7fd3 100644 --- a/bwreg-service/pom.xml +++ b/bwreg-service/pom.xml @@ -271,17 +271,6 @@ <scope>provided</scope> </dependency> - <dependency> - <groupId>edu.kit.scc</groupId> - <artifactId>regapp-jpa-test</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> </dependencies> <build> diff --git a/bwreg-service/src/test/java/edu/kit/scc/webreg/service/impl/RegistryServiceImplTest.java b/bwreg-service/src/test/java/edu/kit/scc/webreg/service/impl/RegistryServiceImplTest.java deleted file mode 100644 index fbd7d35bb..000000000 --- a/bwreg-service/src/test/java/edu/kit/scc/webreg/service/impl/RegistryServiceImplTest.java +++ /dev/null @@ -1,156 +0,0 @@ -package edu.kit.scc.webreg.service.impl; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.time.Instant; -import java.util.Date; -import java.util.List; - -import jakarta.enterprise.inject.Produces; -import jakarta.inject.Inject; - -import org.jboss.weld.junit5.auto.AddBeanClasses; -import org.jboss.weld.junit5.auto.AddPackages; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.TestInstance.Lifecycle; -import org.slf4j.Logger; -import org.slf4j.helpers.NOPLogger; - -import edu.kit.scc.webreg.dao.RegistryDao; -import edu.kit.scc.webreg.dao.SamlIdpMetadataDao; -import edu.kit.scc.webreg.dao.ServiceDao; -import edu.kit.scc.webreg.dao.UserDao; -import edu.kit.scc.webreg.dao.identity.JpaIdentityDao; -import edu.kit.scc.webreg.dao.jpa.JpaBaseDao; -import edu.kit.scc.webreg.dao.test.EnableAutoWeldWithJpaSupport; -import edu.kit.scc.webreg.dao.test.JpaTestConfiguration; -import edu.kit.scc.webreg.entity.AbstractBaseEntity; -import edu.kit.scc.webreg.entity.RegistryEntity; -import edu.kit.scc.webreg.entity.RegistryStatus; -import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity; -import edu.kit.scc.webreg.entity.SamlIdpMetadataEntityStatus; -import edu.kit.scc.webreg.entity.SamlUserEntity; -import edu.kit.scc.webreg.entity.ServiceEntity; -import edu.kit.scc.webreg.entity.UserEntity; -import edu.kit.scc.webreg.event.EventSubmitterImpl; -import edu.kit.scc.webreg.service.RegistryService; - -@EnableAutoWeldWithJpaSupport -@AddPackages(value = { JpaBaseDao.class, JpaIdentityDao.class }, recursively = true) -@AddBeanClasses({ RegistryServiceImpl.class, EventSubmitterImpl.class }) -@TestInstance(Lifecycle.PER_CLASS) -class RegistryServiceImplTest { - - @Produces - public static JpaTestConfiguration produceJpaTestConfiguration() { - return () -> AbstractBaseEntity.class.getPackageName(); - } - - @Produces - public static Logger produceLogger() { - return NOPLogger.NOP_LOGGER; - } - - @Inject - RegistryDao registryDao; - - @Inject - ServiceDao serviceDao; - - @Inject - UserDao userDao; - - @Inject - SamlIdpMetadataDao samlIdpMetadataDao; - - @Inject - RegistryService registryService; - - @Nested - public class FindByServiceAndStatusAndIDPGood { - - @Test - public void findsMatchingRegistries() { - Date lastStatusChange = Date.from(Instant.now().minusSeconds(1L)); - RegistryEntity registry = createRegistryEntity(lastStatusChange, SamlIdpMetadataEntityStatus.GOOD); - - List<RegistryEntity> foundRegistries = registryService.findByServiceAndStatusAndIDPGood("MySSN", RegistryStatus.ACTIVE, - new Date(), 10); - - assertThat(foundRegistries).containsExactly(registry); - } - - @Test - public void ignoresRegistriesAssociatedWithUsersWithFaultyIdpState() { - Date lastStatusChange = Date.from(Instant.now().minusSeconds(1L)); - createRegistryEntity(lastStatusChange, SamlIdpMetadataEntityStatus.FAULTY); - - List<RegistryEntity> foundRegistries = registryService.findByServiceAndStatusAndIDPGood("MySSN", RegistryStatus.ACTIVE, - new Date(), 10); - - assertThat(foundRegistries).isEmpty(); - } - - private RegistryEntity createRegistryEntity(Date lastStatusChange, SamlIdpMetadataEntityStatus idpStatus) { - SamlIdpMetadataEntity samlIdpMetadata = createPersistedSamlIdpMetadataEntity(idpStatus); - UserEntity user = createPersistedSamlUserEntity(samlIdpMetadata); - ServiceEntity service = createPersistedServiceEntity("MySSN"); - return createPersistedRegistryEntity(lastStatusChange, RegistryStatus.ACTIVE, service, user); - } - - } - - private RegistryEntity createPersistedRegistryEntity(Date lastStatusChange, RegistryStatus registryStatus, ServiceEntity service, - UserEntity user) { - return registryDao.persist(createNewRegistryEntity(lastStatusChange, registryStatus, service, user)); - } - - private RegistryEntity createNewRegistryEntity(Date lastStatusChange, RegistryStatus registryStatus, ServiceEntity service, - UserEntity user) { - RegistryEntity registryEntity = new RegistryEntity(); - registryEntity.setLastStatusChange(lastStatusChange); - registryEntity.setRegisterBean("registryRegisterBean"); - registryEntity.setRegistryStatus(registryStatus); - registryEntity.setService(service); - registryEntity.setUser(user); - return registryEntity; - } - - private ServiceEntity createPersistedServiceEntity(String shortName) { - return serviceDao.persist(createNewServiceEntity(shortName)); - } - - private ServiceEntity createNewServiceEntity(String shortName) { - ServiceEntity serviceEntity = new ServiceEntity(); - serviceEntity.setName("serviceName"); - serviceEntity.setShortName(shortName); - serviceEntity.setRegisterBean("serviceRegisterBean"); - return serviceEntity; - } - - private SamlUserEntity createPersistedSamlUserEntity(SamlIdpMetadataEntity samlIdpMetadataEntity) { - return (SamlUserEntity) userDao.persist(createNewSamlUserEntity(samlIdpMetadataEntity)); - } - - private SamlUserEntity createNewSamlUserEntity(SamlIdpMetadataEntity samlIdpMetadataEntity) { - SamlUserEntity samlUserEntity = new SamlUserEntity(); - samlUserEntity.setGivenName("Max"); - samlUserEntity.setIdp(samlIdpMetadataEntity); - samlUserEntity.setSurName("Mustermann"); - samlUserEntity.setUidNumber(4711); - return samlUserEntity; - } - - private SamlIdpMetadataEntity createPersistedSamlIdpMetadataEntity(SamlIdpMetadataEntityStatus aqIdpStatus) { - return samlIdpMetadataDao.persist(createNewSamlIdpMetadataEntity(aqIdpStatus)); - } - - private SamlIdpMetadataEntity createNewSamlIdpMetadataEntity(SamlIdpMetadataEntityStatus aqIdpStatus) { - SamlIdpMetadataEntity samlIdpMetadataEntity = new SamlIdpMetadataEntity(); - samlIdpMetadataEntity.setAqIdpStatus(aqIdpStatus); - return samlIdpMetadataEntity; - } - -} diff --git a/bwreg-service/src/test/java/edu/kit/scc/webreg/service/ssh/SshPubKeyServiceTest.java b/bwreg-service/src/test/java/edu/kit/scc/webreg/service/ssh/SshPubKeyServiceTest.java deleted file mode 100644 index 7a16fa5ab..000000000 --- a/bwreg-service/src/test/java/edu/kit/scc/webreg/service/ssh/SshPubKeyServiceTest.java +++ /dev/null @@ -1,134 +0,0 @@ -package edu.kit.scc.webreg.service.ssh; - -import static java.util.UUID.randomUUID; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; -import java.util.UUID; - -import jakarta.enterprise.inject.Produces; -import jakarta.inject.Inject; -import jakarta.servlet.http.HttpServletRequest; - -import org.jboss.weld.junit5.auto.AddBeanClasses; -import org.jboss.weld.junit5.auto.AddPackages; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.TestInstance.Lifecycle; -import org.mockito.Mockito; -import org.slf4j.Logger; -import org.slf4j.helpers.NOPLogger; - -import edu.kit.scc.webreg.dao.SshPubKeyDao; -import edu.kit.scc.webreg.dao.UserDao; -import edu.kit.scc.webreg.dao.identity.IdentityDao; -import edu.kit.scc.webreg.dao.identity.JpaIdentityDao; -import edu.kit.scc.webreg.dao.jpa.JpaBaseDao; -import edu.kit.scc.webreg.dao.test.EnableAutoWeldWithJpaSupport; -import edu.kit.scc.webreg.dao.test.JpaTestConfiguration; -import edu.kit.scc.webreg.entity.AbstractBaseEntity; -import edu.kit.scc.webreg.entity.SshPubKeyEntity; -import edu.kit.scc.webreg.entity.SshPubKeyStatus; -import edu.kit.scc.webreg.entity.UserEntity; -import edu.kit.scc.webreg.entity.identity.IdentityEntity; -import edu.kit.scc.webreg.event.EventSubmitterImpl; - -@EnableAutoWeldWithJpaSupport -@AddPackages(value = { JpaBaseDao.class, JpaIdentityDao.class }, recursively = true) -@AddBeanClasses({ SshPubKeyServiceImpl.class, EventSubmitterImpl.class }) -@TestInstance(Lifecycle.PER_CLASS) -class SshPubKeyServiceTest { - - @Inject - SshPubKeyService sshPubKeyService; - - @Inject - IdentityDao identityDao; - - @Inject - UserDao userDao; - - @Inject - SshPubKeyDao sshPubKeyDao; - - @Produces - public static JpaTestConfiguration produceJpaTestConfiguration() { - return () -> AbstractBaseEntity.class.getPackageName(); - } - - @Produces - public static HttpServletRequest produceHttpServletRequest() { - return Mockito.mock(HttpServletRequest.class); - } - - @Produces - public static Logger produceLogger() { - return NOPLogger.NOP_LOGGER; - } - - @Nested - public class FindByIdentityAndStatusWithRegs { - - @Test - void returnsCorrectList() { - IdentityEntity identity = createPersistedIdentityEntity("max_mustermann"); - UserEntity user = createPersistedUserEntity(4711, "Max", "Mustermann"); - SshPubKeyEntity sshPubKeyEntity = createPersistedSshPubKeyEntity(identity, user); - - List<SshPubKeyEntity> foundKeys = sshPubKeyService.findByIdentityAndStatusWithRegsAndUser(identity.getId(), SshPubKeyStatus.ACTIVE); - - assertThat(foundKeys).isNotNull().contains(sshPubKeyEntity); - } - - @Test - void returnsEmptyListIfNoneIsFound() { - IdentityEntity identity = createPersistedIdentityEntity("max_mustermann"); - UserEntity user = createPersistedUserEntity(4711, "Max", "Mustermann"); - createPersistedSshPubKeyEntity(identity, user); - - List<SshPubKeyEntity> foundKeys = sshPubKeyService.findByIdentityAndStatusWithRegsAndUser(identity.getId(), SshPubKeyStatus.DELETED); - - assertThat(foundKeys).isEmpty(); - } - - } - - private SshPubKeyEntity createPersistedSshPubKeyEntity(IdentityEntity identity, UserEntity user) { - return sshPubKeyDao.persist(createNewSshPubKeyEntity(identity, user)); - } - - private SshPubKeyEntity createNewSshPubKeyEntity(IdentityEntity identity, UserEntity user) { - SshPubKeyEntity sshPubKeyEntity = new SshPubKeyEntity(); - sshPubKeyEntity.setIdentity(identity); - sshPubKeyEntity.setUser(user); - sshPubKeyEntity.setEncodedKey(UUID.randomUUID().toString()); - sshPubKeyEntity.setKeyStatus(SshPubKeyStatus.ACTIVE); - return sshPubKeyEntity; - } - - private IdentityEntity createPersistedIdentityEntity(String uniqueUsername) { - return identityDao.persist(createNewIdentityEntity(uniqueUsername)); - } - - private IdentityEntity createNewIdentityEntity(String uniqueUsername) { - IdentityEntity identity = new IdentityEntity(); - identity.setChosenLocalUsername(uniqueUsername); - identity.setGeneratedLocalUsername(randomUUID().toString().replace("-", "")); - return identity; - } - - private UserEntity createPersistedUserEntity(Integer uidNumber, String firstName, String surname) { - return userDao.persist(createNewUserEntity(uidNumber, firstName, surname)); - } - - private UserEntity createNewUserEntity(Integer uidNumber, String firstName, String surname) { - UserEntity user = new UserEntity(); - user.setUidNumber(uidNumber); - user.setGivenName(firstName); - user.setSurName(surname); - user.setEmail(String.format("%s.%s@unit.test", firstName, surname)); - return user; - } - -} diff --git a/regapp-jpa-impl/pom.xml b/regapp-jpa-impl/pom.xml index 77db0921f..6f4c705c6 100644 --- a/regapp-jpa-impl/pom.xml +++ b/regapp-jpa-impl/pom.xml @@ -31,12 +31,6 @@ <scope>provided</scope> </dependency> - <dependency> - <groupId>edu.kit.scc</groupId> - <artifactId>regapp-jpa-test</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> </dependencies> <build> -- GitLab