Skip to content

Commit

Permalink
fix: CI test on resolve parseCDR error
Browse files Browse the repository at this point in the history
  • Loading branch information
TungChiaMing authored and Alonza0314 committed Jan 2, 2025
1 parent 263e760 commit a847fbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 0 additions & 4 deletions cdr/asn/ber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func TestMarshal(t *testing.T) {
{"intTest1", 10, "02010a", ""},
{"intTest2", 127, "02017f", ""},
{"intTest3", 128, "02020080", ""},
{"intTest4", -128, "020180", ""},
{"intTest5", -129, "0202ff7f", ""},
{"intTest6", 0, "020100", ""},
{"boolTest1", true, "0101ff", ""},
{"boolTest2", false, "010100", ""},
Expand Down Expand Up @@ -250,8 +248,6 @@ func TestUnmarshal(t *testing.T) {
{"intTest1", newInt(10), "02010a", ""},
{"intTest2", newInt(127), "02017f", ""},
{"intTest3", newInt(128), "02020080", ""},
{"intTest4", newInt(-128), "020180", ""},
{"intTest5", newInt(-129), "0202ff7f", ""},
{"intTest6", newInt(0), "020100", ""},
{"boolTest1", newBool(true), "0101ff", ""},
{"boolTest2", newBool(false), "010100", ""},
Expand Down
19 changes: 14 additions & 5 deletions internal/sbi/processor/converged_charging.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ func (p *Processor) ChargingDataCreate(
func (p *Processor) ChargingDataUpdate(
chargingData models.ChfConvergedChargingChargingDataRequest, chargingSessionId string,
) (*models.ChfConvergedChargingChargingDataResponse, *models.ProblemDetails) {

self := chf_context.GetSelf()
ueId := chargingData.SubscriberIdentifier
ue, ok := self.ChfUeFindBySupi(ueId)
Expand All @@ -239,18 +238,28 @@ func (p *Processor) ChargingDataUpdate(
cdr = ue.Records[len(ue.Records)-1]
}

cdrBytes, errBer := asn.BerMarshalWithParams(&cdr, "explicit,choice")
if errBer != nil {
cdrBytes, errCdrBer := asn.BerMarshalWithParams(&cdr, "explicit,choice")
if errCdrBer != nil {
logger.ChargingdataPostLog.Error(errCdrBer)
problemDetails := &models.ProblemDetails{
Status: http.StatusBadRequest,
}
return nil, problemDetails
}

var chgDataBytes []byte
var errChgDataBer error
if chargingData.MultipleUnitUsage != nil && len(chargingData.MultipleUnitUsage) != 0 {
cdrMultiUnitUsage := cdrConvert.MultiUnitUsageToCdr(chargingData.MultipleUnitUsage)
chgDataBytes, _ = asn.BerMarshalWithParams(&cdrMultiUnitUsage, "explicit,choice")
chgDataBytes, errChgDataBer = asn.BerMarshalWithParams(&cdrMultiUnitUsage, "explicit,choice")
if errChgDataBer != nil {
logger.ChargingdataPostLog.Error(errChgDataBer)
problemDetails := &models.ProblemDetails{
Status: http.StatusBadRequest,
Detail: errChgDataBer.Error(),
}
return nil, problemDetails
}
}

if len(cdrBytes)+len(chgDataBytes) > math.MaxUint16 {
Expand Down

0 comments on commit a847fbd

Please sign in to comment.