@@ -9,6 +9,7 @@ import fr.dcproject.common.email.Mailer
|
||||
import io.ktor.locations.KtorExperimentalLocationsAPI
|
||||
import io.ktor.server.testing.withTestApplication
|
||||
import io.ktor.util.KtorExperimentalAPI
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.InternalCoroutinesApi
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Tags
|
||||
@@ -24,6 +25,7 @@ import org.koin.test.get
|
||||
@Tags(Tag("functional"))
|
||||
class MailerTest : KoinTest, AutoCloseKoinTest() {
|
||||
@InternalCoroutinesApi
|
||||
@ExperimentalCoroutinesApi
|
||||
@Test
|
||||
@Tags(Tag("online"))
|
||||
fun `can be send an email`() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import fr.dcproject.component.citizen.CitizenRef
|
||||
import io.ktor.locations.KtorExperimentalLocationsAPI
|
||||
import io.ktor.server.testing.withTestApplication
|
||||
import io.ktor.util.KtorExperimentalAPI
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import org.amshove.kluent.`should be equal to`
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Tags
|
||||
@@ -19,6 +20,7 @@ import java.util.UUID
|
||||
|
||||
@KtorExperimentalLocationsAPI
|
||||
@KtorExperimentalAPI
|
||||
@ExperimentalCoroutinesApi
|
||||
@TestInstance(PER_CLASS)
|
||||
@Tags(Tag("functional"))
|
||||
class ViewTest {
|
||||
|
||||
@@ -46,13 +46,13 @@ fun createConstitution(
|
||||
): Constitution {
|
||||
val constitutionRepository: ConstitutionRepository by lazy { GlobalContext.get().koin.get() }
|
||||
|
||||
val createdBy: CitizenWithUserI = createCitizen(createdBy)
|
||||
val creator: CitizenWithUserI = createCitizen(createdBy)
|
||||
|
||||
val constitution = ConstitutionSimple(
|
||||
id = id ?: UUID.randomUUID(),
|
||||
title = LoremIpsum().getTitle(3),
|
||||
titles = titles ?: createTitles(5),
|
||||
createdBy = createdBy,
|
||||
createdBy = creator,
|
||||
versionId = UUID.randomUUID()
|
||||
)
|
||||
return constitutionRepository.upsert(constitution) ?: error("Cannot create constitution")
|
||||
|
||||
@@ -34,6 +34,7 @@ fun WorkgroupForView<CitizenCreator>.`With members`(
|
||||
addMemberToWorkgroup(this, *member)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun addMemberToWorkgroup(workgroup: WorkgroupForView<CitizenCreator>, vararg membersNames: CitizenI.Name) {
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val workgroupRepository: WorkgroupRepository by lazy { GlobalContext.get().koin.get() }
|
||||
@@ -58,8 +59,8 @@ private fun createWorkgroup(
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val workgroupRepository: WorkgroupRepository by lazy { GlobalContext.get().koin.get() }
|
||||
|
||||
val createdBy = createdBy ?: CitizenI.Name("Paul", "Langevin")
|
||||
val creator = citizenRepository.findByName(createdBy) ?: run {
|
||||
val creatorName = createdBy ?: CitizenI.Name("Paul", "Langevin")
|
||||
val creator = citizenRepository.findByName(creatorName) ?: run {
|
||||
val username = ("username" + UUID.randomUUID().toString())
|
||||
.toLowerCase().replace(' ', '-')
|
||||
val user = UserForCreate(
|
||||
@@ -67,7 +68,7 @@ private fun createWorkgroup(
|
||||
password = "azerty",
|
||||
)
|
||||
CitizenForCreate(
|
||||
name = createdBy,
|
||||
name = creatorName,
|
||||
email = "$username@dc-project.fr",
|
||||
birthday = DateTime.now(),
|
||||
user = user
|
||||
|
||||
@@ -5,7 +5,7 @@ import fr.dcproject.common.security.AccessDecision.GRANTED
|
||||
import fr.dcproject.component.auth.User
|
||||
import fr.dcproject.component.auth.UserI
|
||||
import fr.dcproject.component.citizen.CitizenAccessControl
|
||||
import fr.dcproject.component.citizen.CitizenBasic
|
||||
import fr.dcproject.component.citizen.CitizenCart
|
||||
import fr.dcproject.component.citizen.CitizenI
|
||||
import org.amshove.kluent.`should be`
|
||||
import org.joda.time.DateTime
|
||||
@@ -20,32 +20,26 @@ import org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT
|
||||
@Execution(CONCURRENT)
|
||||
@Tags(Tag("security"), Tag("unit"))
|
||||
internal class `Citizen Access Control` {
|
||||
private val tesla = CitizenBasic(
|
||||
private val tesla = CitizenCart(
|
||||
user = User(
|
||||
username = "nicolas-tesla",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
birthday = DateTime.now(),
|
||||
email = "tesla@best.com",
|
||||
name = CitizenI.Name("Nicolas", "Tesla")
|
||||
)
|
||||
private val einstein = CitizenBasic(
|
||||
private val einstein = CitizenCart(
|
||||
user = User(
|
||||
username = "albert-einstein",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
birthday = DateTime.now(),
|
||||
email = "einstein@best.com",
|
||||
name = CitizenI.Name("Albert", "Einstein")
|
||||
)
|
||||
|
||||
private val curie = CitizenBasic(
|
||||
private val curie = CitizenCart(
|
||||
user = User(
|
||||
username = "marie-curie",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
birthday = DateTime.now(),
|
||||
email = "curie@best.com",
|
||||
name = CitizenI.Name("Marie", "Curie"),
|
||||
deletedAt = DateTime.now()
|
||||
)
|
||||
|
||||
@@ -6,15 +6,14 @@ import fr.dcproject.component.article.ArticleForView
|
||||
import fr.dcproject.component.auth.User
|
||||
import fr.dcproject.component.auth.UserCreator
|
||||
import fr.dcproject.component.auth.UserI
|
||||
import fr.dcproject.component.citizen.CitizenBasic
|
||||
import fr.dcproject.component.citizen.CitizenCart
|
||||
import fr.dcproject.component.citizen.CitizenCreator
|
||||
import fr.dcproject.component.citizen.CitizenI
|
||||
import fr.dcproject.component.citizen.CitizenRef
|
||||
import fr.dcproject.component.opinion.OpinionAccessControl
|
||||
import fr.dcproject.component.opinion.entity.Opinion
|
||||
import fr.dcproject.component.opinion.entity.OpinionChoice
|
||||
import org.amshove.kluent.`should be`
|
||||
import org.joda.time.DateTime
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Tags
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -36,16 +35,8 @@ internal class `Opinion Access Control` {
|
||||
followAnonymous = false
|
||||
)
|
||||
|
||||
private val einstein = CitizenBasic(
|
||||
private val einstein = CitizenRef(
|
||||
id = UUID.fromString("319f1226-8f47-4df3-babd-2c7671ad0fbc"),
|
||||
user = User(
|
||||
username = "albert-einstein",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
birthday = DateTime.now(),
|
||||
email = "einstein@best.com",
|
||||
name = CitizenI.Name("Albert", "Einstein"),
|
||||
followAnonymous = true
|
||||
)
|
||||
|
||||
private val einstein2 = CitizenCart(
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
package unit.security
|
||||
|
||||
import fr.dcproject.common.security.AccessDecision.GRANTED
|
||||
import fr.dcproject.component.article.ArticleForView
|
||||
import fr.dcproject.component.auth.User
|
||||
import fr.dcproject.component.auth.UserI
|
||||
import fr.dcproject.component.citizen.CitizenBasic
|
||||
import fr.dcproject.component.citizen.CitizenCart
|
||||
import fr.dcproject.component.citizen.CitizenI
|
||||
import fr.dcproject.component.citizen.CitizenRef
|
||||
import fr.dcproject.component.opinion.OpinionChoiceAccessControl
|
||||
import fr.dcproject.component.opinion.entity.OpinionChoice
|
||||
import org.amshove.kluent.`should be`
|
||||
import org.joda.time.DateTime
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Tags
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -23,32 +17,12 @@ import java.util.UUID
|
||||
@Execution(CONCURRENT)
|
||||
@Tags(Tag("security"), Tag("unit"))
|
||||
internal class `OpinionChoice Access Control` {
|
||||
private val tesla = CitizenBasic(
|
||||
private val tesla = CitizenRef(
|
||||
id = UUID.fromString("e6efc288-4283-4729-a268-6debb18de1a0"),
|
||||
user = User(
|
||||
username = "nicolas-tesla",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
birthday = DateTime.now(),
|
||||
email = "tesla@best.com",
|
||||
name = CitizenI.Name("Nicolas", "Tesla"),
|
||||
followAnonymous = false
|
||||
)
|
||||
|
||||
private val tesla2 = CitizenCart(
|
||||
private val tesla2 = CitizenRef(
|
||||
id = UUID.fromString("e6efc288-4283-4729-a268-6debb18de1a0"),
|
||||
user = User(
|
||||
username = "nicolas-tesla",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
name = CitizenI.Name("Nicolas", "Tesla")
|
||||
)
|
||||
|
||||
private val article1 = ArticleForView(
|
||||
content = "Hi",
|
||||
createdBy = tesla2,
|
||||
description = "blablabla",
|
||||
title = "Super article"
|
||||
)
|
||||
|
||||
private val choice1 = OpinionChoice(
|
||||
|
||||
@@ -4,10 +4,11 @@ import fr.dcproject.common.security.AccessDecision.DENIED
|
||||
import fr.dcproject.common.security.AccessDecision.GRANTED
|
||||
import fr.dcproject.component.article.ArticleForView
|
||||
import fr.dcproject.component.auth.User
|
||||
import fr.dcproject.component.auth.UserCreator
|
||||
import fr.dcproject.component.auth.UserI
|
||||
import fr.dcproject.component.citizen.Citizen
|
||||
import fr.dcproject.component.citizen.CitizenBasic
|
||||
import fr.dcproject.component.citizen.CitizenCart
|
||||
import fr.dcproject.component.citizen.CitizenCreator
|
||||
import fr.dcproject.component.citizen.CitizenI
|
||||
import fr.dcproject.component.vote.VoteAccessControl
|
||||
import fr.dcproject.component.vote.entity.VoteForUpdate
|
||||
@@ -20,7 +21,7 @@ import org.junit.jupiter.api.TestInstance
|
||||
import org.junit.jupiter.api.parallel.Execution
|
||||
import org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT
|
||||
import java.util.UUID
|
||||
import fr.dcproject.component.vote.entity.Vote as VoteEntity
|
||||
import fr.dcproject.component.vote.entity.VoteForView
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
@Execution(CONCURRENT)
|
||||
@@ -37,13 +38,11 @@ internal class `Vote Access Control` {
|
||||
name = CitizenI.Name("Nicolas", "Tesla"),
|
||||
followAnonymous = false
|
||||
)
|
||||
private val tesla3 = CitizenBasic(
|
||||
private val tesla3 = CitizenCreator(
|
||||
id = UUID.fromString("a1e35c99-9d33-4fb4-9201-58d7071243bb"),
|
||||
user = User(
|
||||
user = UserCreator(
|
||||
username = "nicolas-tesla",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
birthday = DateTime.now(),
|
||||
email = "tesla@best.com",
|
||||
name = CitizenI.Name("Nicolas", "Tesla"),
|
||||
followAnonymous = false
|
||||
@@ -77,7 +76,7 @@ internal class `Vote Access Control` {
|
||||
title = "Super article"
|
||||
)
|
||||
|
||||
private val vote1 = VoteEntity(
|
||||
private val vote1 = VoteForView(
|
||||
createdBy = tesla3,
|
||||
target = article1,
|
||||
note = 1
|
||||
|
||||
@@ -5,14 +5,13 @@ import fr.dcproject.common.security.AccessDecision.GRANTED
|
||||
import fr.dcproject.component.auth.User
|
||||
import fr.dcproject.component.auth.UserCreator
|
||||
import fr.dcproject.component.auth.UserI
|
||||
import fr.dcproject.component.citizen.CitizenBasic
|
||||
import fr.dcproject.component.citizen.CitizenCart
|
||||
import fr.dcproject.component.citizen.CitizenCreator
|
||||
import fr.dcproject.component.citizen.CitizenI
|
||||
import fr.dcproject.component.citizen.CitizenRef
|
||||
import fr.dcproject.component.workgroup.WorkgroupAccessControl
|
||||
import fr.dcproject.component.workgroup.WorkgroupWithMembersI
|
||||
import org.amshove.kluent.`should be`
|
||||
import org.joda.time.DateTime
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Tags
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -35,25 +34,8 @@ internal class `Workgroup Access Control` {
|
||||
followAnonymous = false
|
||||
)
|
||||
|
||||
private val einstein = CitizenBasic(
|
||||
private val einstein = CitizenRef(
|
||||
id = UUID.fromString("319f1226-8f47-4df3-babd-2c7671ad0fbc"),
|
||||
user = User(
|
||||
username = "albert-einstein",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
birthday = DateTime.now(),
|
||||
email = "einstein@best.com",
|
||||
name = CitizenI.Name("Albert", "Einstein"),
|
||||
followAnonymous = true
|
||||
)
|
||||
|
||||
private val einstein2 = CitizenCart(
|
||||
id = UUID.fromString("319f1226-8f47-4df3-babd-2c7671ad0fbc"),
|
||||
user = User(
|
||||
username = "albert-einstein",
|
||||
roles = listOf(UserI.Roles.ROLE_USER)
|
||||
),
|
||||
name = CitizenI.Name("Albert", "Einstein")
|
||||
)
|
||||
|
||||
private val workgroupPublic = WorkgroupEntity(
|
||||
|
||||
Reference in New Issue
Block a user