lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

June 2024

  • 1 participants
  • 1566 discussions
[M] Change in pysim[master]: add pySim.esim.es9p with definitions of the ES9+ HTTP Interface
by laforge 02 Jun '24

02 Jun '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/36973?usp=email ) Change subject: add pySim.esim.es9p with definitions of the ES9+ HTTP Interface ...................................................................... add pySim.esim.es9p with definitions of the ES9+ HTTP Interface Let's use the infrastructure of pySim.esim.http_json_api to define the ES9+ API Functions. This can in turn be used by clients or even osmo-smdpp can be ported over to using this infratructure rather than open-coding a lot of the encoding/decoding of API request/response parameters. Change-Id: I194ef1d186391f36245c099cc70a4813185ecf9c --- A pySim/esim/es9p.py 1 file changed, 194 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/73/36973/1 diff --git a/pySim/esim/es9p.py b/pySim/esim/es9p.py new file mode 100644 index 0000000..f936a9c --- /dev/null +++ b/pySim/esim/es9p.py @@ -0,0 +1,179 @@ +"""GSMA eSIM RSP ES9+ interface according ot SGP.22 v2.5""" + +# (C) 2024 by Harald Welte <laforge(a)osmocom.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import abc +import requests +import logging +import json +from datetime import datetime +import time +import base64 + +import pySim.esim.rsp as rsp +from pySim.esim.http_json_api import * + +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +class param: + class RspAsn1Par(ApiParamBase64): + """Generalized RSP ASN.1 parameter: base64-wrapped ASN.1 DER. Derived classes must provie + the asn1_type class variable to indicate the name of the ASN.1 type to use for encode/decode.""" + @classmethod + def _decode(cls, data): + data = ApiParamBase64.decode(data) + return rsp.asn1.decode(cls.asn1_type, data) + + @classmethod + def _encode(cls, data): + data = rsp.asn1.encode(cls.asn1_type, data) + return ApiParamBase64.encode(data) + + class EuiccInfo1(RspAsn1Par): + asn1_type = 'EUICCInfo1' + + class ServerSigned1(RspAsn1Par): + asn1_type = 'ServerSigned1' + + class PrepareDownloadResponse(RspAsn1Par): + asn1_type = 'PrepareDownloadResponse' + + class AuthenticateServerResponse(RspAsn1Par): + asn1_type = 'AuthenticateServerResponse' + + class SmdpSigned2(RspAsn1Par): + asn1_type = 'SmdpSigned2' + + class StoreMetadataRequest(RspAsn1Par): + asn1_type = 'StoreMetadataRequest' + + class PendingNotification(RspAsn1Par): + asn1_type = 'PendingNotification' + + class CancelSessionResponse(RspAsn1Par): + asn1_type = 'CancelSessionResponse' + + class TransactionId(ApiParamString): + pass + +class Es9PlusApiFunction(JsonHttpApiFunction): + pass + +# ES9+ InitiateAuthentication function (SGP.22 section 6.5.2.6) +class InitiateAuthentication(Es9PlusApiFunction): + path = '/gsma/rsp2/es9plus/initiateAuthentication' + input_params = { + 'euiccChallenge': ApiParamBase64, + 'euiccInfo1': param.EuiccInfo1, + 'smdpAddress': SmdpAddress, + } + input_mandatory = ['euiccChallenge', 'euiccInfo1', 'smdpAddress'] + output_params = { + 'header': JsonResponseHeader, + 'transactionId': param.TransactionId, + 'serverSigned1': param.ServerSigned1, + 'serverSignature1': ApiParamBase64, + 'euiccCiPKIdToBeUsed': ApiParamBase64, + 'serverCertificate': ApiParamBase64, + } + output_mandatory = ['header', 'transactionId', 'serverSigned1', 'serverSignature1', + 'euiccCiPKIdToBeUsed', 'serverCertificate'] + +# ES9+ GetBoundProfilePackage function (SGP.22 section 6.5.2.7) +class GetBoundProfilePackage(Es9PlusApiFunction): + path = '/gsma/rsp2/es9plus/getBoundProfilePackage' + input_params = { + 'transactionId': param.TransactionId, + 'prepareDownloadResponse': param.PrepareDownloadResponse, + } + input_mandatory = ['transactionId', 'prepareDownloadResponse'] + output_params = { + 'header': JsonResponseHeader, + 'transactionId': param.TransactionId, + 'boundProfilePackage': ApiParamBase64, + } + output_mandatory = ['header', 'transactionId', 'boundProfilePackage'] + +# ES9+ AuthenticateClient function (SGP.22 section 6.5.2.8) +class AuthenticateClient(Es9PlusApiFunction): + path= '/gsma/rsp2/es9plus/authenticateClient' + input_params = { + 'transactionId': param.TransactionId, + 'authenticateServerResponse': param.AuthenticateServerResponse, + } + input_mandatory = ['transactionId', 'authenticateServerResponse'] + output_params = { + 'header': JsonResponseHeader, + 'transactionId': param.TransactionId, + 'profileMetadata': param.StoreMetadataRequest, + 'smdpSigned2': param.SmdpSigned2, + 'smdpSignature2': ApiParamBase64, + 'smdpCertificate': ApiParamBase64, + } + output_mandatory = ['header', 'transactionId', 'profileMetadata', 'smdpSigned2', + 'smdpSignature2', 'smdpCertificate'] + +# ES9+ HandleNotification function (SGP.22 section 6.5.2.9) +class HandleNotification(Es9PlusApiFunction): + path = '/gsma/rsp2/es9plus/handleNotification' + input_params = { + 'pendingNotification': param.PendingNotification, + } + input_mandatory = ['pendingNotification'] + +# ES9+ CancelSession function (SGP.22 section 6.5.2.10) +class CancelSession(Es9PlusApiFunction): + path = '/gsma/rsp2/es9plus/cancelSession' + input_params = { + 'transactionId': param.TransactionId, + 'cancelSessionResponse': param.CancelSessionResponse, + } + input_mandatory = ['transactionId', 'cancelSessionResponse'] + +class Es9pApiClient: + def __init__(self, url_prefix:str, func_req_id:str, server_cert_verify: str = None): + self.func_id = 0 + self.session = requests.Session() + self.session.verify = False # FIXME HACK + if server_cert_verify: + self.session.verify = server_cert_verify + + self.initiateAuthentication = InitiateAuthentication(url_prefix, func_req_id, self.session) + self.authenticateClient = AuthenticateClient(url_prefix, func_req_id, self.session) + self.getBoundProfilePackage = GetBoundProfilePackage(url_prefix, func_req_id, self.session) + self.handleNotification = HandleNotification(url_prefix, func_req_id, self.session) + self.cancelSession = CancelSession(url_prefix, func_req_id, self.session) + + def _gen_func_id(self) -> str: + """Generate the next function call id.""" + self.func_id += 1 + return 'FCI-%u-%u' % (time.time(), self.func_id) + + def call_initiateAuthentication(self, data: dict) -> dict: + return self.initiateAuthentication.call(data, self._gen_func_id()) + + def call_authenticateClient(self, data: dict) -> dict: + return self.authenticateClient.call(data, self._gen_func_id()) + + def call_getBoundProfilePackage(self, data: dict) -> dict: + return self.getBoundProfilePackage.call(data, self._gen_func_id()) + + def call_handleNotification(self, data: dict) -> dict: + return self.handleNotification.call(data, self._gen_func_id()) + + def call_cancelSession(self, data: dict) -> dict: + return self.cancelSession.call(data, self._gen_func_id()) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36973?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I194ef1d186391f36245c099cc70a4813185ecf9c Gerrit-Change-Number: 36973 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[L] Change in pysim[master]: esim.es2p: Split generic part of HTTP/REST API from ES2+
by laforge 02 Jun '24

02 Jun '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/36972?usp=email ) Change subject: esim.es2p: Split generic part of HTTP/REST API from ES2+ ...................................................................... esim.es2p: Split generic part of HTTP/REST API from ES2+ This way we can reuse it for other eSIM RSP HTTP interfaces like ES9+, ES11, ... Change-Id: I468041da40a88875e8df15b04d3ad508e06f16f7 --- M pySim/esim/es2p.py A pySim/esim/http_json_api.py 2 files changed, 276 insertions(+), 230 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/72/36972/1 diff --git a/pySim/esim/es2p.py b/pySim/esim/es2p.py index fa21d2c..b026f9e 100644 --- a/pySim/esim/es2p.py +++ b/pySim/esim/es2p.py @@ -23,90 +23,11 @@ import time import base64 +from pySim.esim.http_json_api import * + logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) -class ApiParam(abc.ABC): - """A class reprsenting a single parameter in the ES2+ API.""" - @classmethod - def verify_decoded(cls, data): - """Verify the decoded reprsentation of a value. Should raise an exception if somthing is odd.""" - pass - - @classmethod - def verify_encoded(cls, data): - """Verify the encoded reprsentation of a value. Should raise an exception if somthing is odd.""" - pass - - @classmethod - def encode(cls, data): - """[Validate and] Encode the given value.""" - cls.verify_decoded(data) - encoded = cls._encode(data) - cls.verify_decoded(encoded) - return encoded - - @classmethod - def _encode(cls, data): - """encoder function, typically [but not always] overridden by derived class.""" - return data - - @classmethod - def decode(cls, data): - """[Validate and] Decode the given value.""" - cls.verify_encoded(data) - decoded = cls._decode(data) - cls.verify_decoded(decoded) - return decoded - - @classmethod - def _decode(cls, data): - """decoder function, typically [but not always] overridden by derived class.""" - return data - -class ApiParamString(ApiParam): - """Base class representing an API parameter of 'string' type.""" - pass - - -class ApiParamInteger(ApiParam): - """Base class representing an API parameter of 'integer' type.""" - @classmethod - def _decode(cls, data): - return int(data) - - @classmethod - def _encode(cls, data): - return str(data) - - @classmethod - def verify_decoded(cls, data): - if not isinstance(data, int): - raise TypeError('Expected an integer input data type') - - @classmethod - def verify_encoded(cls, data): - if isinstance(data, int): - return - if not data.isdecimal(): - raise ValueError('integer (%s) contains non-decimal characters' % data) - assert str(int(data)) == data - -class ApiParamBoolean(ApiParam): - """Base class representing an API parameter of 'boolean' type.""" - @classmethod - def _encode(cls, data): - return bool(data) - -class ApiParamFqdn(ApiParam): - """String, as a list of domain labels concatenated using the full stop (dot, period) character as - separator between labels. Labels are restricted to the Alphanumeric mode character set defined in table 5 - of ISO/IEC 18004""" - @classmethod - def verify_encoded(cls, data): - # FIXME - pass - class param: class Iccid(ApiParamString): """String representation of 19 or 20 digits, where the 20th digit MAY optionally be the padding @@ -172,9 +93,6 @@ class SmdsAddress(ApiParamFqdn): pass - class SmdpAddress(ApiParamFqdn): - pass - class ReleaseFlag(ApiParamBoolean): pass @@ -197,150 +115,12 @@ class NotificationPointStatus(ApiParam): pass - class ResultData(ApiParam): - @classmethod - def _decode(cls, data): - return base64.b64decode(data) + class ResultData(ApiParamBase64): + pass - @classmethod - def _encode(cls, data): - return base64.b64encode(data) - - class JsonResponseHeader(ApiParam): - """SGP.22 section 6.5.1.4.""" - @classmethod - def verify_decoded(cls, data): - fe_status = data.get('functionExecutionStatus') - if not fe_status: - raise ValueError('Missing mandatory functionExecutionStatus in header') - status = fe_status.get('status') - if not status: - raise ValueError('Missing mandatory status in header functionExecutionStatus') - if status not in ['Executed-Success', 'Executed-WithWarning', 'Failed', 'Expired']: - raise ValueError('Unknown/unspecified status "%s"' % status) - - -class HttpStatusError(Exception): - pass - -class HttpHeaderError(Exception): - pass - -class Es2PlusApiError(Exception): - """Exception representing an error at the ES2+ API level (status != Executed).""" - def __init__(self, func_ex_status: dict): - self.status = func_ex_status['status'] - sec = { - 'subjectCode': None, - 'reasonCode': None, - 'subjectIdentifier': None, - 'message': None, - } - actual_sec = func_ex_status.get('statusCodeData', None) - sec.update(actual_sec) - self.subject_code = sec['subjectCode'] - self.reason_code = sec['reasonCode'] - self.subject_id = sec['subjectIdentifier'] - self.message = sec['message'] - - def __str__(self): - return f'{self.status}("{self.subject_code}","{self.reason_code}","{self.subject_id}","{self.message}")' - -class Es2PlusApiFunction(abc.ABC): +class Es2PlusApiFunction(JsonHttpApiFunction): """Base classs for representing an ES2+ API Function.""" - # the below class variables are expected to be overridden in derived classes - - path = None - # dictionary of input parameters. key is parameter name, value is ApiParam class - input_params = {} - # list of mandatory input parameters - input_mandatory = [] - # dictionary of output parameters. key is parameter name, value is ApiParam class - output_params = {} - # list of mandatory output parameters (for successful response) - output_mandatory = [] - # expected HTTP status code of the response - expected_http_status = 200 - # the HTTP method used (GET, OPTIONS, HEAD, POST, PUT, PATCH or DELETE) - http_method = 'POST' - - def __init__(self, url_prefix: str, func_req_id: str, session): - self.url_prefix = url_prefix - self.func_req_id = func_req_id - self.session = session - - def encode(self, data: dict, func_call_id: str) -> dict: - """Validate an encode input dict into JSON-serializable dict for request body.""" - output = { - 'header': { - 'functionRequesterIdentifier': self.func_req_id, - 'functionCallIdentifier': func_call_id - } - } - for p in self.input_mandatory: - if not p in data: - raise ValueError('Mandatory input parameter %s missing' % p) - for p, v in data.items(): - p_class = self.input_params.get(p) - if not p_class: - logger.warning('Unexpected/unsupported input parameter %s=%s', p, v) - output[p] = v - else: - output[p] = p_class.encode(v) - return output - - - def decode(self, data: dict) -> dict: - """[further] Decode and validate the JSON-Dict of the respnse body.""" - output = {} - # let's first do the header, it's special - if not 'header' in data: - raise ValueError('Mandatory output parameter "header" missing') - hdr_class = self.output_params.get('header') - output['header'] = hdr_class.decode(data['header']) - - if output['header']['functionExecutionStatus']['status'] not in ['Executed-Success','Executed-WithWarning']: - raise Es2PlusApiError(output['header']['functionExecutionStatus']) - # we can only expect mandatory parameters to be present in case of successful execution - for p in self.output_mandatory: - if p == 'header': - continue - if not p in data: - raise ValueError('Mandatory output parameter "%s" missing' % p) - for p, v in data.items(): - p_class = self.output_params.get(p) - if not p_class: - logger.warning('Unexpected/unsupported output parameter "%s"="%s"', p, v) - output[p] = v - else: - output[p] = p_class.decode(v) - return output - - def call(self, data: dict, func_call_id:str, timeout=10) -> dict: - """Make an API call to the ES2+ API endpoint represented by this object. - Input data is passed in `data` as json-serializable dict. Output data - is returned as json-deserialized dict.""" - url = self.url_prefix + self.path - encoded = json.dumps(self.encode(data, func_call_id)) - headers = { - 'Content-Type': 'application/json', - 'X-Admin-Protocol': 'gsma/rsp/v2.5.0', - } - - logger.debug("HTTP REQ %s - '%s'" % (url, encoded)) - response = self.session.request(self.http_method, url, data=encoded, headers=headers, timeout=timeout) - logger.debug("HTTP RSP-STS: [%u] hdr: %s" % (response.status_code, response.headers)) - logger.debug("HTTP RSP: %s" % (response.content)) - - if response.status_code != self.expected_http_status: - raise HttpStatusError(response) - if not response.headers.get('Content-Type').startswith(headers['Content-Type']): - raise HttpHeaderError(response) - if not response.headers.get('X-Admin-Protocol', 'gsma/rsp/v2.unknown').startswith('gsma/rsp/v2.'): - raise HttpHeaderError(response) - - return self.decode(response.json()) - + pass # ES2+ DownloadOrder function (SGP.22 section 5.3.1) class DownloadOrder(Es2PlusApiFunction): @@ -351,7 +131,7 @@ 'profileType': param.ProfileType } output_params = { - 'header': param.JsonResponseHeader, + 'header': JsonResponseHeader, 'iccid': param.Iccid, } output_mandatory = ['header', 'iccid'] @@ -369,7 +149,7 @@ } input_mandatory = ['iccid', 'releaseFlag'] output_params = { - 'header': param.JsonResponseHeader, + 'header': JsonResponseHeader, 'eid': param.Eid, 'matchingId': param.MatchingId, 'smdpAddress': param.SmdpAddress, @@ -387,7 +167,7 @@ } input_mandatory = ['finalProfileStatusIndicator', 'iccid'] output_params = { - 'header': param.JsonResponseHeader, + 'header': JsonResponseHeader, } output_mandatory = ['header'] @@ -399,7 +179,7 @@ } input_mandatory = ['iccid'] output_params = { - 'header': param.JsonResponseHeader, + 'header': JsonResponseHeader, } output_mandatory = ['header'] diff --git a/pySim/esim/http_json_api.py b/pySim/esim/http_json_api.py new file mode 100644 index 0000000..ec9cd00 --- /dev/null +++ b/pySim/esim/http_json_api.py @@ -0,0 +1,254 @@ +"""GSMA eSIM RSP HTTP/REST/JSON interface according to SGP.22 v2.5""" + +# (C) 2024 by Harald Welte <laforge(a)osmocom.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import abc +import requests +import logging +import json +from datetime import datetime +import time +import base64 + +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +class ApiParam(abc.ABC): + """A class reprsenting a single parameter in the API.""" + @classmethod + def verify_decoded(cls, data): + """Verify the decoded reprsentation of a value. Should raise an exception if somthing is odd.""" + pass + + @classmethod + def verify_encoded(cls, data): + """Verify the encoded reprsentation of a value. Should raise an exception if somthing is odd.""" + pass + + @classmethod + def encode(cls, data): + """[Validate and] Encode the given value.""" + cls.verify_decoded(data) + encoded = cls._encode(data) + cls.verify_decoded(encoded) + return encoded + + @classmethod + def _encode(cls, data): + """encoder function, typically [but not always] overridden by derived class.""" + return data + + @classmethod + def decode(cls, data): + """[Validate and] Decode the given value.""" + cls.verify_encoded(data) + decoded = cls._decode(data) + cls.verify_decoded(decoded) + return decoded + + @classmethod + def _decode(cls, data): + """decoder function, typically [but not always] overridden by derived class.""" + return data + +class ApiParamString(ApiParam): + """Base class representing an API parameter of 'string' type.""" + pass + + +class ApiParamInteger(ApiParam): + """Base class representing an API parameter of 'integer' type.""" + @classmethod + def _decode(cls, data): + return int(data) + + @classmethod + def _encode(cls, data): + return str(data) + + @classmethod + def verify_decoded(cls, data): + if not isinstance(data, int): + raise TypeError('Expected an integer input data type') + + @classmethod + def verify_encoded(cls, data): + if isinstance(data, int): + return + if not data.isdecimal(): + raise ValueError('integer (%s) contains non-decimal characters' % data) + assert str(int(data)) == data + +class ApiParamBoolean(ApiParam): + """Base class representing an API parameter of 'boolean' type.""" + @classmethod + def _encode(cls, data): + return bool(data) + +class ApiParamFqdn(ApiParam): + """String, as a list of domain labels concatenated using the full stop (dot, period) character as + separator between labels. Labels are restricted to the Alphanumeric mode character set defined in table 5 + of ISO/IEC 18004""" + @classmethod + def verify_encoded(cls, data): + # FIXME + pass + +class ApiParamBase64(ApiParam): + @classmethod + def _decode(cls, data): + return base64.b64decode(data) + + @classmethod + def _encode(cls, data): + return base64.b64encode(data).decode('ascii') + +class SmdpAddress(ApiParamFqdn): + pass + +class JsonResponseHeader(ApiParam): + """SGP.22 section 6.5.1.4.""" + @classmethod + def verify_decoded(cls, data): + fe_status = data.get('functionExecutionStatus') + if not fe_status: + raise ValueError('Missing mandatory functionExecutionStatus in header') + status = fe_status.get('status') + if not status: + raise ValueError('Missing mandatory status in header functionExecutionStatus') + if status not in ['Executed-Success', 'Executed-WithWarning', 'Failed', 'Expired']: + raise ValueError('Unknown/unspecified status "%s"' % status) + + +class HttpStatusError(Exception): + pass + +class HttpHeaderError(Exception): + pass + +class ApiError(Exception): + """Exception representing an error at the API level (status != Executed).""" + def __init__(self, func_ex_status: dict): + self.status = func_ex_status['status'] + sec = { + 'subjectCode': None, + 'reasonCode': None, + 'subjectIdentifier': None, + 'message': None, + } + actual_sec = func_ex_status.get('statusCodeData', None) + sec.update(actual_sec) + self.subject_code = sec['subjectCode'] + self.reason_code = sec['reasonCode'] + self.subject_id = sec['subjectIdentifier'] + self.message = sec['message'] + + def __str__(self): + return f'{self.status}("{self.subject_code}","{self.reason_code}","{self.subject_id}","{self.message}")' + +class JsonHttpApiFunction(abc.ABC): + """Base classs for representing an HTTP[s] API Function.""" + # the below class variables are expected to be overridden in derived classes + + path = None + # dictionary of input parameters. key is parameter name, value is ApiParam class + input_params = {} + # list of mandatory input parameters + input_mandatory = [] + # dictionary of output parameters. key is parameter name, value is ApiParam class + output_params = {} + # list of mandatory output parameters (for successful response) + output_mandatory = [] + # expected HTTP status code of the response + expected_http_status = 200 + # the HTTP method used (GET, OPTIONS, HEAD, POST, PUT, PATCH or DELETE) + http_method = 'POST' + + def __init__(self, url_prefix: str, func_req_id: str, session: requests.Session): + self.url_prefix = url_prefix + self.func_req_id = func_req_id + self.session = session + + def encode(self, data: dict, func_call_id: str) -> dict: + """Validate an encode input dict into JSON-serializable dict for request body.""" + output = { + 'header': { + 'functionRequesterIdentifier': self.func_req_id, + 'functionCallIdentifier': func_call_id + } + } + for p in self.input_mandatory: + if not p in data: + raise ValueError('Mandatory input parameter %s missing' % p) + for p, v in data.items(): + p_class = self.input_params.get(p) + if not p_class: + logger.warning('Unexpected/unsupported input parameter %s=%s', p, v) + output[p] = v + else: + output[p] = p_class.encode(v) + return output + + def decode(self, data: dict) -> dict: + """[further] Decode and validate the JSON-Dict of the respnse body.""" + output = {} + # let's first do the header, it's special + if not 'header' in data: + raise ValueError('Mandatory output parameter "header" missing') + hdr_class = self.output_params.get('header') + output['header'] = hdr_class.decode(data['header']) + + if output['header']['functionExecutionStatus']['status'] not in ['Executed-Success','Executed-WithWarning']: + raise ApiError(output['header']['functionExecutionStatus']) + # we can only expect mandatory parameters to be present in case of successful execution + for p in self.output_mandatory: + if p == 'header': + continue + if not p in data: + raise ValueError('Mandatory output parameter "%s" missing' % p) + for p, v in data.items(): + p_class = self.output_params.get(p) + if not p_class: + logger.warning('Unexpected/unsupported output parameter "%s"="%s"', p, v) + output[p] = v + else: + output[p] = p_class.decode(v) + return output + + def call(self, data: dict, func_call_id:str, timeout=10) -> dict: + """Make an API call to the HTTP API endpoint represented by this object. + Input data is passed in `data` as json-serializable dict. Output data + is returned as json-deserialized dict.""" + url = self.url_prefix + self.path + encoded = json.dumps(self.encode(data, func_call_id)) + headers = { + 'Content-Type': 'application/json', + 'X-Admin-Protocol': 'gsma/rsp/v2.5.0', + } + + logger.debug("HTTP REQ %s - '%s'" % (url, encoded)) + response = self.session.request(self.http_method, url, data=encoded, headers=headers, timeout=timeout) + logger.debug("HTTP RSP-STS: [%u] hdr: %s" % (response.status_code, response.headers)) + logger.debug("HTTP RSP: %s" % (response.content)) + + if response.status_code != self.expected_http_status: + raise HttpStatusError(response) + if not response.headers.get('Content-Type').startswith(headers['Content-Type']): + raise HttpHeaderError(response) + if not response.headers.get('X-Admin-Protocol', 'gsma/rsp/v2.unknown').startswith('gsma/rsp/v2.'): + raise HttpHeaderError(response) + + return self.decode(response.json()) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36972?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I468041da40a88875e8df15b04d3ad508e06f16f7 Gerrit-Change-Number: 36972 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: pySim.esim.saip: Meaningful constructors for [I]SD + SSD
by laforge 02 Jun '24

02 Jun '24
Attention is currently required from: laforge. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/36961?usp=email to look at the new patch set (#3). The following approvals got outdated and were removed: Verified+1 by Jenkins Builder Change subject: pySim.esim.saip: Meaningful constructors for [I]SD + SSD ...................................................................... pySim.esim.saip: Meaningful constructors for [I]SD + SSD So far the main use case was to read a ProfileElement-SD from a DER file. But when we want to construct one from scratch, we need to have the constructor put some meaningful [default] values into the class members. Change-Id: I69e104f1d78165c12291317326dbab05977a1574 --- M pySim/esim/saip/__init__.py 1 file changed, 85 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/61/36961/3 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36961?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I69e104f1d78165c12291317326dbab05977a1574 Gerrit-Change-Number: 36961 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in osmo-bts[master]: common: add support for TW-TS-001
by falconia 02 Jun '24

02 Jun '24
Attention is currently required from: osmith, pespin. falconia has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/36896?usp=email ) Change subject: common: add support for TW-TS-001 ...................................................................... Patch Set 4: Verified+1 (1 comment) Patchset: PS4: This patch has been tested on real hardware (sysmoBTS) and verified to work as intended: standard RTP output (RFC 3551) in normal operation, TW-TS-001 RTP output if the special IE is given via RSL. -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/36896?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: Id997e8666bc19e60936aaa83b43a968d30320bd7 Gerrit-Change-Number: 36896 Gerrit-PatchSet: 4 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Sun, 02 Jun 2024 09:44:34 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in ...osmo-epdg[master]: README.md: fix copy-pasted 'osmo-bsc' and a broken link
by fixeria 01 Jun '24

01 Jun '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/36968?usp=email ) Change subject: README.md: fix copy-pasted 'osmo-bsc' and a broken link ...................................................................... README.md: fix copy-pasted 'osmo-bsc' and a broken link Change-Id: I760db277ee682298d8c7a4d11cf68c86d94fe368 --- M README.md 1 file changed, 12 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-epdg refs/changes/68/36968/1 diff --git a/README.md b/README.md index bcd616b..4fa1c15 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ GIT Repository -------------- -You can clone from the official osmo-bsc.git repository using +You can clone from the official osmo-epdg.git repository using git clone https://gitea.osmocom.org/erlang/osmo-epdg @@ -52,8 +52,8 @@ <https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit> for more details -The current patch queue for osmo-bsc can be seen at -<https://gerrit.osmocom.org/#/q/project:osmo-epdg+status:open> +The current patch queue for osmo-epdg can be seen at +<https://gerrit.osmocom.org/#/q/project:erlang/osmo-epdg+status:open> Building -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/36968?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-epdg Gerrit-Branch: master Gerrit-Change-Id: I760db277ee682298d8c7a4d11cf68c86d94fe368 Gerrit-Change-Number: 36968 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in osmo-bts[master]: common: add support for TW-TS-001
by falconia 01 Jun '24

01 Jun '24
Attention is currently required from: osmith, pespin. falconia has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/36896?usp=email ) Change subject: common: add support for TW-TS-001 ...................................................................... Patch Set 4: (2 comments) This change is ready for review. File src/common/l1sap.c: https://gerrit.osmocom.org/c/osmo-bts/+/36896/comment/67eaea98_9303058b PS1, Line 1998: uint8_t teh; > Trau-like Extension Header, see the text of TW-TS-001 spec. Done File src/common/rtp_input_preen.c: https://gerrit.osmocom.org/c/osmo-bts/+/36896/comment/64b03db5_b6a712a3 PS1, Line 104: /* Strip TEH octet, leaving only standard EFR payload. */ > Ack Compilation builds are now passing thanks to libosmocore patches being merged, but Jenkins builder is still marking this patch as V-1 because of the linter tripping up on TEH. What do we do? Is there any kind of manual override? Or do we need to patch osmo-ci.git like @osmith@sysmocom.de originally suggested, and then maybe put that "teh||the" line back in after this osmo-bts patch is merged? -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/36896?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: Id997e8666bc19e60936aaa83b43a968d30320bd7 Gerrit-Change-Number: 36896 Gerrit-PatchSet: 4 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Sat, 01 Jun 2024 00:37:54 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: osmith <osmith(a)sysmocom.de> Comment-In-Reply-To: falconia <falcon(a)freecalypso.org> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 154
  • 155
  • 156
  • 157
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.