Create CI #78

Merged
flecomte merged 4 commits from action into master 2021-03-24 19:12:41 +01:00
15 changed files with 245 additions and 207 deletions
Showing only changes of commit 52183abd08 - Show all commits

View File

@@ -1,22 +1,22 @@
package integration
import integration.steps.then.`And have property`
import integration.steps.then.`And the response should contain pattern`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body`
import integration.steps.then.`whish contains`
import integration.steps.then.and
import integration.steps.given.`Given I have article created by workgroup`
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have articles`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have workgroup`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And have property`
import integration.steps.then.`And the response should contain list`
import integration.steps.then.`And the response should contain pattern`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`And the response should not contain`
import integration.steps.then.`Then the response should be`
import integration.steps.then.`whish contains`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Tags
@@ -84,7 +84,8 @@ class `Article routes` : BaseTest() {
`Given I have citizen`("John", "Doe")
`When I send a POST request`("/articles") {
`authenticated as`("John", "Doe")
`with body`("""
`with body`(
"""
{
"versionId": "09c418b6-63ba-448b-b38b-502b41cd500e",
"title": "title2",
@@ -95,7 +96,8 @@ class `Article routes` : BaseTest() {
"green"
]
}
""")
"""
)
} `Then the response should be` OK and {
`And the response should not be null`()
`And have property`("$.versionId") `whish contains` "09c418b6-63ba-448b-b38b-502b41cd500e"

View File

@@ -1,16 +1,16 @@
package integration
import integration.steps.`when`.Validate
import integration.steps.then.`And have property`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
import integration.steps.then.`whish contains`
import integration.steps.then.and
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And have property`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.`whish contains`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.BadRequest
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
@@ -66,12 +66,14 @@ class `Citizen routes` : BaseTest() {
`Given I have citizen`("Georges", "Charpak", id = "0c966522-4071-43e5-a3ca-cfff2557f2cf")
`When I send a PUT request`("/citizens/0c966522-4071-43e5-a3ca-cfff2557f2cf/password/change") {
`authenticated as`("Georges", "Charpak")
`with body`("""
`with body`(
"""
{
"oldPassword": "azerty",
"newPassword": "qwerty"
}
""")
"""
)
} `Then the response should be` Created
}
}
@@ -82,12 +84,14 @@ class `Citizen routes` : BaseTest() {
`Given I have citizen`("Louis", "Breguet", id = "6cf2a19d-d15d-4ee5-b2a9-907afd26b525")
`When I send a PUT request`("/citizens/6cf2a19d-d15d-4ee5-b2a9-907afd26b525/password/change", Validate.ALL - Validate.REQUEST_BODY) {
`authenticated as`("Louis", "Breguet")
`with body`("""
`with body`(
"""
{
"plup": "azerty",
"gloup": "qwerty"
}
""")
"""
)
} `Then the response should be` BadRequest
}
}

View File

@@ -1,18 +1,18 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
import integration.steps.then.`And the response should contain`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
import integration.steps.then.and
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
@@ -30,11 +30,13 @@ class `Comment articles routes` : BaseTest() {
`Given I have article`(id = "aa16c635-28da-46f0-9a89-934eef88c7ca")
`When I send a POST request`("/articles/aa16c635-28da-46f0-9a89-934eef88c7ca/comments") {
`authenticated as`("Michael", "Faraday")
`with body`("""
`with body`(
"""
{
"content": "Hello mister"
}
""")
"""
)
} `Then the response should be` Created and {
`And the response should not be null`()
`And the response should contain`("$.target.id", "aa16c635-28da-46f0-9a89-934eef88c7ca")
@@ -99,11 +101,13 @@ class `Comment articles routes` : BaseTest() {
`Given I have comment on article`(article = "bb05e4a3-55a1-4088-85e7-8d8c23be29b1", createdBy = Name("Hubert", "Reeves"), id = "fd30d20f-656c-42c6-8955-f61c04537464")
`When I send a PUT request`("/comments/fd30d20f-656c-42c6-8955-f61c04537464") {
`authenticated as`("Hubert", "Reeves")
`with body`("""
`with body`(
"""
{
"content": "Hello boy"
}
""")
"""
)
} `Then the response should be` OK and {
`And the response should not be null`()
`And the response should contain`("$.content", "Hello boy")

View File

@@ -1,18 +1,18 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
import integration.steps.then.`And the response should contain list`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body`
import integration.steps.then.and
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on constitution`
import integration.steps.given.`Given I have constitution`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And the response should contain list`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
@@ -30,11 +30,13 @@ class `Comment constitutions routes` : BaseTest() {
`Given I have constitution`(id = "1707c287-a472-4a62-89f2-9e85030e915c")
`When I send a POST request`("/constitutions/1707c287-a472-4a62-89f2-9e85030e915c/comments") {
`authenticated as`("Nicolas", "Copernic")
`with body`("""
`with body`(
"""
{
"content": "Hello mister"
}
""")
"""
)
} `Then the response should be` Created and {
`And the response should not be null`()
}

View File

@@ -1,13 +1,13 @@
package integration
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.then.and
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Tags

View File

@@ -1,18 +1,18 @@
package integration
import integration.steps.`when`.Validate
import integration.steps.then.`And have property`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body`
import integration.steps.then.`whish contains`
import integration.steps.then.and
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have constitution`
import integration.steps.given.`Given I have constitutions`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And have property`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.`whish contains`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.BadRequest
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
@@ -66,7 +66,8 @@ class `Constitution routes` : BaseTest() {
`Given I have citizen`("Henri", "Poincaré")
`When I send a POST request`("/constitutions") {
`authenticated as`("Henri", "Poincaré")
`with body`("""
`with body`(
"""
{
"versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
"title":"Hello world!",
@@ -77,7 +78,8 @@ class `Constitution routes` : BaseTest() {
}
]
}
""")
"""
)
} `Then the response should be` Created and {
`And the response should not be null`()
`And have property`("$.versionId") `whish contains` "15814bb6-8d90-4c6a-a456-c3939a8ec75e"
@@ -92,7 +94,8 @@ class `Constitution routes` : BaseTest() {
`Given I have citizen`("Henri", "Poincaré")
`When I send a POST request`("/constitutions", Validate.ALL - Validate.REQUEST_BODY) {
`authenticated as`("Henri", "Poincaré")
`with body`("""
`with body`(
"""
{
"versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
"title":"Hello world!",
@@ -104,7 +107,8 @@ class `Constitution routes` : BaseTest() {
}
]
}
""")
"""
)
} `Then the response should be` BadRequest
}
}

View File

@@ -1,18 +1,18 @@
package integration
import integration.steps.then.`And the response should be null`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a DELETE request`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.then.and
import integration.steps.given.`And follow article`
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content`
import integration.steps.then.`And the response should be null`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK

View File

@@ -1,18 +1,18 @@
package integration
import integration.steps.then.`And the response should be null`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a DELETE request`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.then.and
import integration.steps.given.`And follow constitution`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have constitution`
import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content`
import integration.steps.then.`And the response should be null`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK

View File

@@ -1,12 +1,12 @@
package integration
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.`and should contains`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And the response should not be null`
import integration.steps.then.`Then the response should be`
import integration.steps.then.`and should contains`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK
@@ -23,12 +23,14 @@ class `Login routes` : BaseTest() {
withIntegrationApplication {
`Given I have citizen`("Niels", "Bohr")
`When I send a POST request`("/login") {
`with body`("""
`with body`(
"""
{
"username": "niels-bohr",
"password": "azerty"
}
""")
"""
)
} `Then the response should be` OK and {
`And the response should not be null`() `and should contains` "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9."
// TODO valid requestBody
@@ -42,12 +44,14 @@ class `Login routes` : BaseTest() {
`Given I have citizen`("Leonhard", "Euler", "fabrice.lecomte.be@gmail.com", id = "c606110c-ff0e-4d09-a79e-74632d7bf7bd")
`When I send a POST request`("/auth/passwordless") {
`authenticated as`("Leonhard", "Euler")
`with body`("""
`with body`(
"""
{
"url": "https://dc-project.fr/password/reset",
"email": "fabrice.lecomte.be@gmail.com"
}
""")
"""
)
} `Then the response should be` NoContent
}
}

View File

@@ -1,18 +1,18 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
import integration.steps.then.`And the response should contain list`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
import integration.steps.then.and
import integration.steps.given.`Given I have an opinion choice`
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have opinion on article`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And the response should contain list`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`Then the response should be`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
@@ -55,13 +55,15 @@ class `Opinion routes` : BaseTest() {
`Given I have article`(id = "9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b", createdBy = Name("Isaac", "Newton"))
`When I send a PUT request`("/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/opinions") {
`authenticated as`("Isaac", "Newton")
`with body`("""
`with body`(
"""
{
"ids": [
"0f4f1721-3136-44f1-9f31-1459f3317b15"
]
}
""")
"""
)
} `Then the response should be` Created
}
}

View File

@@ -22,7 +22,8 @@ class `Register routes` : BaseTest() {
fun `I can register`() {
withIntegrationApplication {
`When I send a POST request`("/register") {
`with body`("""
`with body`(
"""
{
"name": {"firstName":"George", "lastName":"MICHEL"},
"birthday": "2001-01-01",
@@ -32,7 +33,8 @@ class `Register routes` : BaseTest() {
},
"email": "george-junior@gmail.com"
}
""")
"""
)
} `Then the response should be` OK and {
`And the response should not be null`()
`And the response should contain pattern`("$.token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.")
@@ -44,7 +46,8 @@ class `Register routes` : BaseTest() {
fun `I cannot register if no username was sent`() {
withIntegrationApplication {
`When I send a POST request`("/register", Validate.ALL - Validate.REQUEST_BODY) {
`with body`("""
`with body`(
"""
{
"name": {"firstName":"George2", "lastName":"MICHEL2"},
"birthday": "2001-01-01",
@@ -53,7 +56,8 @@ class `Register routes` : BaseTest() {
},
"email": "george-junior@gmail.com"
}
""")
"""
)
} `Then the response should be` BadRequest and {
`And the response should be null`()
}

View File

@@ -1,12 +1,9 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
import integration.steps.then.`And the response should contain`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
import integration.steps.then.and
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article`
@@ -14,6 +11,9 @@ import integration.steps.given.`Given I have constitution`
import integration.steps.given.`Given I have vote +1 on article`
import integration.steps.given.`Given I have vote -1 on article`
import integration.steps.given.`authenticated as`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`Then the response should be`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
@@ -31,11 +31,13 @@ class `Vote routes` : BaseTest() {
`Given I have article`(id = "835c5101-ca39-4038-a4e6-da6ee62ca6d5")
`When I send a PUT request`("/articles/835c5101-ca39-4038-a4e6-da6ee62ca6d5/vote") {
`authenticated as`("Thalès", "Milet")
`with body`("""
`with body`(
"""
{
"note": 1
}
""")
"""
)
} `Then the response should be` Created
}
}
@@ -47,11 +49,13 @@ class `Vote routes` : BaseTest() {
`Given I have constitution`(id = "76e79c89-efc1-492d-9e8f-dc9717363a11")
`When I send a PUT request`("/constitutions/76e79c89-efc1-492d-9e8f-dc9717363a11/vote") {
`authenticated as`("Gregor", "Mendel")
`with body`("""
`with body`(
"""
{
"note": 1
}
""")
"""
)
} `Then the response should be` Created
}
}
@@ -102,11 +106,13 @@ class `Vote routes` : BaseTest() {
)
`When I send a PUT request`("/comments/e793eccc-456b-4450-a292-46d592229b74/vote") {
`authenticated as`("Antoine", "Lavoisier")
`with body`("""
`with body`(
"""
{
"note": -1
}
""")
"""
)
} `Then the response should be` Created and {
`And the response should contain`("$.down", 1)
}

View File

@@ -1,21 +1,21 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
import integration.steps.then.`And the response should be null`
import integration.steps.then.`And the response should contain list`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a DELETE request`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
import integration.steps.then.and
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have workgroup`
import integration.steps.given.`With members`
import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content`
import integration.steps.then.`And the response should be null`
import integration.steps.then.`And the response should contain list`
import integration.steps.then.`And the response should contain`
import integration.steps.then.`Then the response should be`
import integration.steps.then.and
import integration.steps.then.`And have property`
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent
@@ -68,14 +68,16 @@ class `Workgroup routes` : BaseTest() {
`Given I have citizen`("Werner", "Heisenberg")
`When I send a POST request`("/workgroups") {
`authenticated as`("Werner", "Heisenberg")
`with body`("""
`with body`(
"""
{
"id":"f496d86d-6654-4068-91ff-90e1dbcc5f38",
"name":"Les Bouffons",
"description":"La vie est belle",
"anonymous":false
}
""")
"""
)
} `Then the response should be` Created and {
`And the response should contain`("$.id", "f496d86d-6654-4068-91ff-90e1dbcc5f38")
`And the response should contain`("$.name", "Les Bouffons")
@@ -171,7 +173,8 @@ class `Workgroup routes` : BaseTest() {
`Given I have workgroup`("b0ea1922-3bc6-44e2-aa7c-40158998cfbb", createdBy = Name("Blaise", "Pascal"))
`When I send a POST request`("/workgroups/b0ea1922-3bc6-44e2-aa7c-40158998cfbb/members") {
`authenticated as`("Blaise", "Pascal")
`with body`("""
`with body`(
"""
[
{
"citizen": {"id":"6d883fe7-5fc0-4a50-8858-72230673eba4"},
@@ -182,7 +185,8 @@ class `Workgroup routes` : BaseTest() {
"roles": ["MASTER"]
}
]
""")
"""
)
} `Then the response should be` Created
}
}
@@ -231,7 +235,8 @@ class `Workgroup routes` : BaseTest() {
}
`When I send a PUT request`("/workgroups/784fe6bc-7635-4ae2-b080-3a4743b998bf/members") {
`authenticated as`("Leon", "Foucault")
`with body`("""
`with body`(
"""
[
{
"citizen": {"id":"be3b0926-8628-4426-804a-75188a6eb315"},
@@ -242,7 +247,8 @@ class `Workgroup routes` : BaseTest() {
"roles": ["MASTER"]
}
]
""")
"""
)
} `Then the response should be` OK and {
`And the response should contain list`("$", 2, 2)
`And the response should contain`("$.[0]citizen.id", "be3b0926-8628-4426-804a-75188a6eb315")

View File

@@ -11,6 +11,7 @@ import fr.dcproject.component.citizen.database.CitizenCreator
import fr.dcproject.component.citizen.database.CitizenI
import fr.dcproject.component.vote.VoteAccessControl
import fr.dcproject.component.vote.database.VoteForUpdate
import fr.dcproject.component.vote.database.VoteForView
import org.amshove.kluent.`should be`
import org.joda.time.DateTime
import org.junit.jupiter.api.Tag
@@ -20,7 +21,6 @@ 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.database.VoteForView
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Execution(CONCURRENT)