diff --git a/.idea/runConfigurations/Follow_Tests.xml b/.idea/runConfigurations/Follow_Tests.xml
new file mode 100644
index 0000000..819c167
--- /dev/null
+++ b/.idea/runConfigurations/Follow_Tests.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Mark_as__error.xml b/.idea/runConfigurations/Mark_as__error.xml
new file mode 100644
index 0000000..d02e5f3
--- /dev/null
+++ b/.idea/runConfigurations/Mark_as__error.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Opinion_Tests.xml b/.idea/runConfigurations/Opinion_Tests.xml
new file mode 100644
index 0000000..327b968
--- /dev/null
+++ b/.idea/runConfigurations/Opinion_Tests.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/kotlin/feature/KtorServerAuthSteps.kt b/src/test/kotlin/feature/KtorServerAuthSteps.kt
index 55def43..33ef0f4 100644
--- a/src/test/kotlin/feature/KtorServerAuthSteps.kt
+++ b/src/test/kotlin/feature/KtorServerAuthSteps.kt
@@ -5,7 +5,6 @@ import fr.dcproject.JwtConfig
import fr.dcproject.entity.Citizen
import fr.dcproject.entity.CitizenI
import fr.dcproject.entity.User
-import fr.dcproject.utils.toUUID
import fr.postgresjson.connexion.Requester
import io.cucumber.datatable.DataTable
import io.cucumber.java8.En
@@ -16,29 +15,27 @@ import org.koin.test.get
import org.koin.test.inject
import java.util.*
import java.util.concurrent.CompletionException
-import kotlin.random.Random
import fr.dcproject.repository.Citizen as CitizenRepository
class KtorServerAuthSteps : En, KoinTest {
private val requester: Requester by inject()
init {
When("I have citizen:") { body: DataTable ->
- val user = User(username = "jaque_${Random.nextInt(0, 10000)}", plainPassword = "azerty")
- requester
- .getFunction("insert_user")
- .selectOne(user)
-
val data = body.asMap(String::class.java, String::class.java)
+ val username = (data["firstName"] + "-" + data["lastName"]).toLowerCase()
+ val user = User(
+ username = username,
+ plainPassword = "azerty"
+ )
val citizen = Citizen(
id = UUID.fromString(data["id"]),
name = CitizenI.Name(data["firstName"]!!, data["lastName"]!!),
- email = data["email"] ?: ((data["firstName"] + "-" + data["lastName"]).toLowerCase()) + "@dc-project.com",
+ email = data["email"] ?: "$username@dc-project.com",
birthday = DateTime.now(),
user = user
)
- requester
- .getFunction("upsert_citizen")
- .selectOne(citizen)
+
+ get().insertWithUser(citizen)
}
Given("I am authenticated as {word} {word} with id {string}") { firstName: String, lastName: String, id: String ->
@@ -71,8 +68,8 @@ class KtorServerAuthSteps : En, KoinTest {
}
}
- Given("I have citizen {word} {word}") { firstName: String, lastName: String, extraInfo: DataTable? ->
- val id: UUID = extraInfo?.asMap(String::class.java, String::class.java)?.get("id")?.toUUID() ?: UUID.randomUUID()
+ Given("I have citizen {word} {word}") { firstName: String, lastName: String ->
+ val id: UUID = UUID.randomUUID()
val user = User(
id = id,
@@ -95,7 +92,7 @@ class KtorServerAuthSteps : En, KoinTest {
val citizen = get().findByUsername(username) ?: error("Cititzen not exist with username $username")
val jwtAsString: String = JWT.create()
.withIssuer("dc-project.fr")
- .withClaim("id", citizen.id.toString())
+ .withClaim("id", citizen.user.id.toString())
.sign(JwtConfig.algorithm)
KtorServerContext.defaultServer.addPreRequestSetup {
diff --git a/src/test/resources/feature/opinion.feature b/src/test/resources/feature/opinion.feature
index b35ea2c..98eff39 100644
--- a/src/test/resources/feature/opinion.feature
+++ b/src/test/resources/feature/opinion.feature
@@ -14,8 +14,10 @@ Feature: Opinion
| [0]name | Opinion1 |
Scenario: Can create opinion on article
- Given I have citizen Isaac Newton
- | id | 2f414045-95d9-42ca-a3a9-8cdde52ad253 |
+ Given I have citizen:
+ | id | 2f414045-95d9-42ca-a3a9-8cdde52ad253 |
+ | firstName | Isaac |
+ | lastName | Newton |
And I am authenticated as Isaac Newton
And I have article
| id | 9226c1a3-8091-c3fa-7d0d-c2e98c9bee7 |
@@ -45,8 +47,10 @@ Feature: Opinion
| opinions.Opinion2 | 1 |
Scenario: Can get all opinion of one citizen
- Given I have citizen Albert Einstein
- | id | c1542096-3431-432d-8e35-9dc071d4c818 |
+ Given I have citizen:
+ | id | c1542096-3431-432d-8e35-9dc071d4c818 |
+ | firstName | Albert |
+ | lastName | Einstein |
And I am authenticated as Albert Einstein
And I have an opinion
| opinion | Opinion1 |