-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enkel ktor integrasjonstest av signeringssertifikatendepunkt i cparepo
- Loading branch information
Showing
3 changed files
with
57 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
cpa-repo/src/main/kotlin/no/nav/emottak/cpa/model/ValidateRequest.kt
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
cpa-repo/src/test/kotlin/no/nav/emottak/cpa/CPARepoIntegrationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package no.nav.emottak.cpa | ||
|
||
import io.ktor.client.call.body | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.client.request.post | ||
import io.ktor.client.request.setBody | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.HttpStatusCode | ||
import io.ktor.http.contentType | ||
import io.ktor.serialization.kotlinx.json.json | ||
import io.ktor.server.testing.testApplication | ||
import no.nav.emottak.melding.model.SignatureDetails | ||
import no.nav.emottak.melding.model.SignatureDetailsRequest | ||
import org.junit.jupiter.api.Assertions.* | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.TestInstance | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class CPARepoIntegrationTest { | ||
|
||
@Test | ||
fun `Hent sertifikat for signatursjekk`() = testApplication { | ||
application { myApplicationModule() } | ||
val request = SignatureDetailsRequest( | ||
cpaId = "cpaId", //TODO endres hvis/når respons fra getCpa ikke lenger er hardkodet | ||
partyType = "HER", | ||
partyId = "8141253", | ||
role = "Behandler", | ||
service = "BehandlerKrav", | ||
action = "OppgjorsMelding" | ||
) | ||
val httpClient = createClient { | ||
install(ContentNegotiation) { | ||
json() | ||
} | ||
} | ||
val response = httpClient.post("/signing/certificate") { | ||
setBody(request) | ||
contentType(ContentType.Application.Json) | ||
} | ||
val body = response.body<SignatureDetails>() | ||
assertEquals(HttpStatusCode.OK, response.status) | ||
assertEquals("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", body.signatureAlgorithm) | ||
assertEquals("http://www.w3.org/2001/04/xmlenc#sha256", body.hashFunction) | ||
} | ||
|
||
} | ||
|