Skip to content

Commit

Permalink
validation error added for session_id check
Browse files Browse the repository at this point in the history
  • Loading branch information
ikaratass committed Aug 10, 2022
1 parent 0be1f20 commit 35fdfcd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
5 changes: 3 additions & 2 deletions iso15118/shared/messages/din_spec/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ def check_sessionid_is_hexbinary(cls, value):
int(value, 16)
return value
except ValueError as exc:
raise ValueError(
raise V2GMessageValidationError(
f"Invalid value '{value}' for EVCCID (must be "
f"hexadecimal representation of max 6 bytes)"
f"hexadecimal representation of max 6 bytes)",
ResponseCode.FAILED_SEQUENCE_ERROR, None
) from exc


Expand Down
8 changes: 5 additions & 3 deletions iso15118/shared/messages/din_spec/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

from pydantic import Field, validator

from iso15118.shared.exceptions import V2GMessageValidationError
from iso15118.shared.messages import BaseModel
from iso15118.shared.messages.din_spec.datatypes import Notification
from iso15118.shared.messages.din_spec.datatypes import Notification, ResponseCode
from iso15118.shared.messages.xmldsig import Signature


Expand Down Expand Up @@ -43,7 +44,8 @@ def check_sessionid_is_hexbinary(cls, value):
int(value, 16)
return value
except ValueError as exc:
raise ValueError(
raise V2GMessageValidationError(
f"Invalid value '{value}' for SessionID (must be "
f"hexadecimal representation of max 8 bytes)"
f"hexadecimal representation of max 8 bytes)",
ResponseCode.FAILED_SEQUENCE_ERROR, None
) from exc
10 changes: 6 additions & 4 deletions iso15118/shared/messages/iso15118_2/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,10 @@ def check_sessionid_is_hexbinary(cls, value):
int(value, 16)
return value
except ValueError as exc:
raise ValueError(
raise V2GMessageValidationError(
f"Invalid value '{value}' for SessionID (must be "
f"hexadecimal representation of max 8 bytes)"
f"hexadecimal representation of max 8 bytes)",
ResponseCode.FAILED_SEQUENCE_ERROR, None
) from exc


Expand Down Expand Up @@ -609,9 +610,10 @@ def check_sessionid_is_hexbinary(cls, value):
int(value, 16)
return value
except ValueError as exc:
raise ValueError(
raise V2GMessageValidationError(
f"Invalid value '{value}' for EVCCID (must be "
f"hexadecimal representation of max 6 bytes)"
f"hexadecimal representation of max 6 bytes)",
ResponseCode.FAILED_SEQUENCE_ERROR, None
) from exc


Expand Down
8 changes: 5 additions & 3 deletions iso15118/shared/messages/iso15118_2/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

from pydantic import Field, validator

from iso15118.shared.exceptions import V2GMessageValidationError
from iso15118.shared.messages import BaseModel
from iso15118.shared.messages.iso15118_2.datatypes import Notification
from iso15118.shared.messages.iso15118_2.datatypes import Notification, ResponseCode
from iso15118.shared.messages.xmldsig import Signature


Expand Down Expand Up @@ -43,7 +44,8 @@ def check_sessionid_is_hexbinary(cls, value):
int(value, 16)
return value
except ValueError as exc:
raise ValueError(
raise V2GMessageValidationError(
f"Invalid value '{value}' for SessionID (must be "
f"hexadecimal representation of max 8 bytes)"
f"hexadecimal representation of max 8 bytes)",
ResponseCode.FAILED_SEQUENCE_ERROR, None
) from exc
8 changes: 5 additions & 3 deletions iso15118/shared/messages/iso15118_20/common_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from pydantic import Field, root_validator, validator

from iso15118.shared.exceptions import V2GMessageValidationError
from iso15118.shared.messages import BaseModel
from iso15118.shared.messages.enums import (
INT_8_MAX,
Expand All @@ -41,7 +42,7 @@
Receipt,
RootCertificateIDList,
V2GRequest,
V2GResponse,
V2GResponse, ResponseCode,
)
from iso15118.shared.validators import one_field_must_be_set

Expand Down Expand Up @@ -1092,9 +1093,10 @@ def check_sessionid_is_hexbinary(cls, value):
int(value, 16)
return value
except ValueError as exc:
raise ValueError(
raise V2GMessageValidationError(
f"Invalid value '{value}' for SessionID (must be "
f"hexadecimal representation of max 8 bytes)"
f"hexadecimal representation of max 8 bytes)",
ResponseCode.FAILED_SEQUENCE_ERROR, None
) from exc


Expand Down
6 changes: 4 additions & 2 deletions iso15118/shared/messages/iso15118_20/common_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from pydantic import Field, conbytes, conint, constr, validator

from iso15118.shared.exceptions import V2GMessageValidationError
from iso15118.shared.messages import BaseModel
from iso15118.shared.messages.enums import (
INT_8_MAX,
Expand Down Expand Up @@ -63,9 +64,10 @@ def check_sessionid_is_hexbinary(cls, value):
int(value, 16)
return value
except ValueError as exc:
raise ValueError(
raise V2GMessageValidationError(
f"Invalid value '{value}' for SessionID (must be "
f"hexadecimal representation of max 8 bytes)"
f"hexadecimal representation of max 8 bytes)",
ResponseCode.FAILED_SEQUENCE_ERROR, None
) from exc


Expand Down

0 comments on commit 35fdfcd

Please sign in to comment.