Skip to content

Commit

Permalink
Merge pull request #116 from IZIVIA/fix/#115-credentials-sample-401-e…
Browse files Browse the repository at this point in the history
…rror

fix(sample) #115: 401 error in credentials sample
  • Loading branch information
lilgallon authored Jun 27, 2024
2 parents f21a60f + 6006cc5 commit 93a128b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ open class PartnerCacheRepository : PartnerRepository {

override suspend fun savePartnerUrlForTokenA(tokenA: String, partnerUrl: String): String? = partners
.toList()
.firstOrNull { it.tokenA == tokenA }
?.copy(url = partnerUrl)
?.also { partners[it.url!!] = it }
?.url
.indexOfFirst { it.tokenA == tokenA }
.let { index ->
partners[index] = partners[index].copy(url = partnerUrl)
partnerUrl
}

override suspend fun saveCredentialsRoles(
partnerUrl: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun main() {
serverVersionsUrlProvider = { receiverVersionsUrl },
requiredEndpoints = requiredOtherPartEndpoints
),
receiverVersionsRepository
versionsRepository = receiverVersionsRepository
).registerOn(receiverServer)
VersionsServer(
service = VersionsService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import com.izivia.ocpi.toolkit.modules.credentials.services.CredentialsClientSer
import com.izivia.ocpi.toolkit.modules.credentials.services.RequiredEndpoints
import com.izivia.ocpi.toolkit.modules.locations.domain.BusinessDetails
import com.izivia.ocpi.toolkit.modules.versions.VersionsServer
import com.izivia.ocpi.toolkit.modules.versions.domain.Endpoint
import com.izivia.ocpi.toolkit.modules.versions.domain.InterfaceRole
import com.izivia.ocpi.toolkit.modules.versions.domain.ModuleID
import com.izivia.ocpi.toolkit.modules.versions.domain.VersionNumber
import com.izivia.ocpi.toolkit.modules.versions.repositories.InMemoryVersionsRepository
import com.izivia.ocpi.toolkit.modules.versions.services.VersionsService
import com.izivia.ocpi.toolkit.samples.common.Http4kTransportClientBuilder
Expand Down Expand Up @@ -38,9 +41,14 @@ fun main() {
VersionsServer(
service = VersionsService(
repository = senderVersionsRepository,
baseUrlProvider = { receiverUrl }
baseUrlProvider = { senderUrl }
)
).registerOn(senderServer)

senderVersionsRepository.addEndpoint(
VersionNumber.V2_2_1,
Endpoint(ModuleID.credentials, InterfaceRole.SENDER, "$senderUrl/2.2.1/credentials")
)
}
senderServer.start()

Expand Down

0 comments on commit 93a128b

Please sign in to comment.