Skip to content

Commit

Permalink
feat: treat key codes like any other token
Browse files Browse the repository at this point in the history
KeyCodes should probably be associated with specific charge stations
as they're supposed to represent things like PINs. However, in the
absence of support for this in MaEVe at the moment, treating them
like an RFID token offers better support than just rejecting them
outright.
  • Loading branch information
subnova committed Mar 21, 2024
1 parent 12cfeb6 commit 74f0d91
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
5 changes: 0 additions & 5 deletions manager/services/token_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ func (o *OcppTokenAuthService) Authorize(ctx context.Context, token ocpp201.IdTo
tokenInfo = &ocpp201.IdTokenInfoType{
Status: ocpp201.AuthorizationStatusEnumTypeAccepted,
}
case ocpp201.IdTokenEnumTypeKeyCode:
// PENDING: check key codes for charge station
tokenInfo = &ocpp201.IdTokenInfoType{
Status: ocpp201.AuthorizationStatusEnumTypeInvalid,
}
case ocpp201.IdTokenEnumTypeLocal:
// local auth must be implemented in a different TokenAuthService
tokenInfo = &ocpp201.IdTokenInfoType{
Expand Down
39 changes: 0 additions & 39 deletions manager/services/token_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,45 +86,6 @@ func TestOcppTokenAuthServiceAcceptsCentral(t *testing.T) {
})
}

// PENDING: this describes the current behaviour
// working assumption is that the pin codes should be associated
// with the charge station, so we need to add this to the
// charge station model
func TestOcppTokenAuthServiceRejectsKeyCode(t *testing.T) {
now := time.Now()
clock := fakeclock.NewFakePassiveClock(now)
tokenStore := inmemory.NewStore(clock)

tokenAuthService := services.OcppTokenAuthService{
TokenStore: tokenStore,
Clock: clock,
}

tracer, exporter := testutil.GetTracer()

ctx := context.Background()

func() {
ctx, span := tracer.Start(ctx, "test")
defer span.End()

tokenInfo := tokenAuthService.Authorize(ctx, ocpp201.IdTokenType{
Type: ocpp201.IdTokenEnumTypeKeyCode,
IdToken: "1234",
})

assert.Equal(t, ocpp201.IdTokenInfoType{
Status: ocpp201.AuthorizationStatusEnumTypeInvalid,
}, tokenInfo)
}()

testutil.AssertSpan(t, &exporter.GetSpans()[0], "test", map[string]any{
"token_auth.type": "KeyCode",
"token_auth.id": "1234",
"token_auth.status": "Invalid",
})
}

func TestOcppTokenAuthServiceRejectsLocalAuth(t *testing.T) {
now := time.Now()
clock := fakeclock.NewFakePassiveClock(now)
Expand Down

0 comments on commit 74f0d91

Please sign in to comment.