lte/gateway/c/session_manager/test/test_session_state.cpp
// We want to test a case where we receive a GSU with credit 0, but we
// receive a final_action on credit exhaust.
We want to test a case where we receive a GSU with credit 0, but we
receive a final_action on credit exhaust.
We want to test a case where we receive a GSU with credit 0 but we receive a final_action on credit exhaust .
TEST_F(SessionStateTest, test_zero_gsu_credit_grant) {
  insert_rule(1, "m1", "rule1", STATIC, 0, 0);
  CreditUpdateResponse charge_resp;
  charge_resp.set_success(true);
  charge_resp.set_sid(IMSI1);
  charge_resp.set_charging_key(1);
  auto p_credit = charge_resp.mutable_credit();
  uint64_t zero = 0;
  p_credit->set_type(ChargingCredit::BYTES);
  p_credit->set_is_final(true);
  p_credit->set_final_action(ChargingCredit_FinalAction_TERMINATE);
  create_granted_units(&zero, &zero, &zero, p_credit->mutable_granted_units());
  EXPECT_TRUE(
      session_state->receive_charging_credit(charge_resp, &update_criteria));
  EXPECT_EQ(update_criteria.charging_credit_to_install.size(), 1);
  auto u_credit = update_criteria.charging_credit_to_install[1];
  EXPECT_TRUE(u_credit.is_final);
  EXPECT_EQ(u_credit.final_action_info.final_action,
            ChargingCredit_FinalAction_TERMINATE);
  EXPECT_EQ(u_credit.credit.grant_tracking_type, TRACKING_UNSET);
  EXPECT_EQ(u_credit.credit.buckets[ALLOWED_TOTAL], 0);
  EXPECT_EQ(u_credit.credit.buckets[ALLOWED_TX], 0);
  EXPECT_EQ(u_credit.credit.buckets[ALLOWED_RX], 0);
  session_state->add_rule_usage("rule1", 1, 100, 100, 0, 0, &update_criteria);
  auto credit_uc = update_criteria.charging_credit_map[1];
  EXPECT_EQ(credit_uc.service_state, SERVICE_NEEDS_DEACTIVATION);
}
TEST_F ( SessionStateTest , test_zero_gsu_credit_grant ) { insert_rule ( 1 , " " , " " , STATIC , 0 , 0 ) ; CreditUpdateResponse charge_resp ; charge_resp . set_success ( true ) ; charge_resp . set_sid ( IMSI1 ) ; charge_resp . set_charging_key ( 1 ) ; auto p_credit = charge_resp . mutable_credit ( ) ; uint64_t zero = 0 ; p_credit -> set_type ( ChargingCredit :: BYTES ) ; p_credit -> set_is_final ( true ) ; p_credit -> set_final_action ( ChargingCredit_FinalAction_TERMINATE ) ; create_granted_units ( & zero , & zero , & zero , p_credit -> mutable_granted_units ( ) ) ; EXPECT_TRUE ( session_state -> receive_charging_credit ( charge_resp , & update_criteria ) ) ; EXPECT_EQ ( update_criteria . charging_credit_to_install . size ( ) , 1 ) ; auto u_credit = update_criteria . charging_credit_to_install [ 1 ] ; EXPECT_TRUE ( u_credit . is_final ) ; EXPECT_EQ ( u_credit . final_action_info . final_action , ChargingCredit_FinalAction_TERMINATE ) ; EXPECT_EQ ( u_credit . credit . grant_tracking_type , TRACKING_UNSET ) ; EXPECT_EQ ( u_credit . credit . buckets [ ALLOWED_TOTAL ] , 0 ) ; EXPECT_EQ ( u_credit . credit . buckets [ ALLOWED_TX ] , 0 ) ; EXPECT_EQ ( u_credit . credit . buckets [ ALLOWED_RX ] , 0 ) ; session_state -> add_rule_usage ( " " , 1 , 100 , 100 , 0 , 0 , & update_criteria ) ; auto credit_uc = update_criteria . charging_credit_map [ 1 ] ; EXPECT_EQ ( credit_uc . service_state , SERVICE_NEEDS_DEACTIVATION ) ; }
We want to test a case where we receive a GSU with credit 0, but we
receive a final_action on credit exhaust.
We want to test a case where we receive a GSU with credit 0 but we receive a final_action on credit exhaust .
// A ChargingCredit with 0 GSU and FinalAction // Test that the update criteria is filled out properly // At this point, the charging credit for RG=1 should have no available quota // and the tracking should be TRACKING_UNSET // Report some rule usage, and ensure the final action gets triggered