Skip to content

Commit

Permalink
test: Use Authorization header instead of url parms in TestClientServ…
Browse files Browse the repository at this point in the history
…ice (#3398)
  • Loading branch information
seakayone authored Oct 22, 2024
1 parent 791a1d7 commit 22d433e
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,19 @@ final case class TestClientService(
*/
def uploadToSipi(loginToken: String, files: Seq[FileToUpload]): Task[SipiUploadResponse] =
for {
url <- ZIO.succeed(targetHostUri.addPath("upload").addParam("token", loginToken))
url <- ZIO.succeed(targetHostUri.addPath("upload"))
multiparts = files.map { file =>
multipartFile("file", file.path.toFile)
.fileName(file.path.getFileName.toString)
.contentType(file.mimeType.toString)
}
response <- doSipiRequest(quickRequest.post(url).multipartBody(multiparts))
json <- ZIO.fromEither(response.fromJson[SipiUploadResponse]).mapError(Throwable(_))
response <- doSipiRequest(
quickRequest
.post(url)
.header("Authorization", s"Bearer $loginToken")
.multipartBody(multiparts),
)
json <- ZIO.fromEither(response.fromJson[SipiUploadResponse]).mapError(Throwable(_))
} yield json

/**
Expand Down

0 comments on commit 22d433e

Please sign in to comment.