From 74f0d914c18702f225384e1c61d360c655db9161 Mon Sep 17 00:00:00 2001 From: Dale Peakall Date: Thu, 21 Mar 2024 13:53:32 +0000 Subject: [PATCH] feat: treat key codes like any other token 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. --- manager/services/token_auth.go | 5 ---- manager/services/token_auth_test.go | 39 ----------------------------- 2 files changed, 44 deletions(-) diff --git a/manager/services/token_auth.go b/manager/services/token_auth.go index 9ab6046..581725e 100644 --- a/manager/services/token_auth.go +++ b/manager/services/token_auth.go @@ -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{ diff --git a/manager/services/token_auth_test.go b/manager/services/token_auth_test.go index 3d819a0..589cfb6 100644 --- a/manager/services/token_auth_test.go +++ b/manager/services/token_auth_test.go @@ -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)