Skip to content

Commit

Permalink
Feature/toggle service interface (#34)
Browse files Browse the repository at this point in the history
* integrate permissions contract and setup integration test

Signed-off-by: Adam Staveley <[email protected]>

* integrate new permissions contract with updated getters

Signed-off-by: Adam Staveley <[email protected]>

* create async task service for request forwarding

Signed-off-by: Adam Staveley <[email protected]>

* move EnableAsync/Scheduling to Configuration bean; fix tests not building

Signed-off-by: Adam Staveley <[email protected]>

* bump version; upgrade notary to fix brotli errors on windows/darwin

Signed-off-by: Adam Staveley <[email protected]>

* provide more context to async tasks

Signed-off-by: Adam Staveley <[email protected]>

* separate registry related methods from routing service; trigger async app forwarding task using valid message variable

Signed-off-by: Adam Staveley <[email protected]>

* split requestHandlerBuilder into separate request and response handlers

Signed-off-by: Adam Staveley <[email protected]>

* convert request handler service test to separate component tests; add missing licenses

Signed-off-by: Adam Staveley <[email protected]>

* modify request handler api and rework tests

Signed-off-by: Adam Staveley <[email protected]>

* cleanup including organisation of imports

Signed-off-by: Adam Staveley <[email protected]>

* rename OcpiRequestHandler.forward overrides; implement forwardAgain method

Signed-off-by: Adam Staveley <[email protected]>

* replace event listener with forwarding in the same thread

Signed-off-by: Adam Staveley <[email protected]>

* test app interface with local and remote message forwarding

Signed-off-by: Adam Staveley <[email protected]>

* add tests for OcnAppPermissions enum matcher methods and RegistryService.getAgreementsByInterface()

Signed-off-by: Adam Staveley <[email protected]>

* fix BigInteger instantiation in registyr test case and update changelog

* intial custom modules controller and unit test

Signed-off-by: Adam Staveley <[email protected]>

* start integrating custom modules into request handling flow

Signed-off-by: Adam Staveley <[email protected]>

* custom modules controller test; further custom module id integration; rename ocpi request variable properties

Signed-off-by: Adam Staveley <[email protected]>

* Merged in feature/app-give-permissions (pull request #29)

give the permission of 4-17

Signed-off-by: Arzon <[email protected]>

Approved-by: Adam Staveley <[email protected]>

* integrate custom modules into ocnrules

Signed-off-by: Adam Staveley <[email protected]>

* change custom module path placement and update asciidoc documentation

Signed-off-by: Adam Staveley <[email protected]>

* clean docs and fix custom module mapping matching

Signed-off-by: Adam Staveley <[email protected]>

* rename app to service

* set service/permission option

Signed-off-by: Arzon <[email protected]>

* changed variable name

Signed-off-by: Arzon <[email protected]>

---------

Signed-off-by: Adam Staveley <[email protected]>
Signed-off-by: Adam Staveley <[email protected]>
Signed-off-by: Arzon <[email protected]>
Co-authored-by: Adam Staveley <[email protected]>
Co-authored-by: Adam Staveley <[email protected]>
Co-authored-by: Arzon Barua <[email protected]>
  • Loading branch information
4 people authored Aug 13, 2024
1 parent 9bdc6cc commit c2d8a90
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Includes initial hubclientinfo OCPI module implementation.
- Optional "Planned Party" search scans registry for newly planned parties at regular intervals.
- New configuration properties under `ocn.node`: `stillAliveEnabled`, `stillAliveRate`,
`plannedPartySearchEnabled`, `plannedPartySearchRate`.

## 1.0.0
### Mar 03, 2020

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import snc.openchargingnetwork.node.services.HttpService
import snc.openchargingnetwork.node.services.RegistryService
import snc.openchargingnetwork.node.tools.*


@RestController
@RequestMapping("/ocpi/2.2/credentials")
class CredentialsController(private val platformRepo: PlatformRepository,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package snc.openchargingnetwork.node.integration

import org.awaitility.kotlin.await
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.springframework.http.HttpMethod
import snc.openchargingnetwork.node.integration.utils.*
import snc.openchargingnetwork.node.models.OcnServicePermission
import snc.openchargingnetwork.node.models.ocpi.InterfaceRole
import snc.openchargingnetwork.node.models.ocpi.ModuleID
import java.util.concurrent.TimeUnit

class ServiceInterfaceTest {

// TODO: integration test setup could be in an inheritable class
private lateinit var networkComponents: NetworkComponents
private lateinit var cpo1: TestCpo
private lateinit var cpo2: TestCpo
private lateinit var msp: TestMsp


@BeforeEach
fun bootStrap() {
networkComponents = setupNetwork(HubClientInfoParams())
cpo1 = networkComponents.cpos[0]
cpo2 = networkComponents.cpos[1]
msp = networkComponents.msps.first()
}

@AfterEach
fun stopTestParties() {
stopPartyServers(networkComponents)
}

private fun seenByBothCpos(): Boolean {
val message = ReceivedMessage(
module = ModuleID.LOCATIONS,
interfaceRole = InterfaceRole.SENDER,
method = HttpMethod.GET,
sender = msp.party)
val cpo1Seen = cpo1.server.messageStore.contains(message)
val cpo2Seen = cpo2.server.messageStore.contains(message)
return cpo1Seen && cpo2Seen
}

private fun testForwarding(recipient: TestCpo, service: TestCpo) {
service.server.setServicePermissions(listOf(OcnServicePermission.FORWARD_ALL))
msp.server.agreeToServicePermissions(service.address)
msp.server.getLocation(recipient.party)
await.atMost(2L, TimeUnit.SECONDS).until { seenByBothCpos() }
}

@Test
fun fowardsRequestToService_Local() {
testForwarding(recipient = cpo2, service = cpo1)

}

@Test
fun fowardsRequestToService_Remote() {
testForwarding(recipient = cpo1, service = cpo2)
}

}

0 comments on commit c2d8a90

Please sign in to comment.