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 2807596 commit 7e06058
Show file tree
Hide file tree
Showing 2 changed files with 23 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
28 changes: 23 additions & 5 deletions internal/sbi/processor/converged_charging.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,24 +238,42 @@ 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,
Detail: errCdrBer.Error(),
}
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 {
var newRecord *cdrType.CHFRecord
cdrJson, _ := json.Marshal(cdr)
json.Unmarshal(cdrJson, &newRecord)
cdrJson, err := json.Marshal(cdr)
if err != nil {
logger.ChargingdataPostLog.Error(err)
}
err = json.Unmarshal(cdrJson, &newRecord)
if err != nil {
logger.ChargingdataPostLog.Error(err)
}

newRecord.ChargingFunctionRecord.ListOfMultipleUnitUsage = []cdrType.MultipleUnitUsage{}
cdr = newRecord
ue.Records = append(ue.Records, cdr)
Expand Down

0 comments on commit 7e06058

Please sign in to comment.