Exemplo n.º 1
0
void SipTest::register_uri(RegStore* store,
                           FakeHSSConnection* hss,
                           const std::string& user,
                           const std::string& domain,
                           const std::string& contact,
                           int lifetime,
                           std::string instance_id)
{
  string uri("sip:");
  uri.append(user).append("@").append(domain);
  if (hss)
  {
    hss->set_impu_result(uri, "call", HSSConnection::STATE_REGISTERED, "");
  }
  RegStore::AoR* aor = store->get_aor_data(uri, 0);
  RegStore::AoR::Binding* binding = aor->get_binding(contact);
  binding->_uri = contact;
  binding->_cid = "1";
  binding->_cseq = 1;
  binding->_expires = time(NULL) + lifetime;
  binding->_priority = 1000;
  binding->_emergency_registration = false;
  if (!instance_id.empty())
  {
    binding->_params["+sip.instance"] = instance_id;
  }
  bool ret = store->set_aor_data(uri, aor, false, 0);
  delete aor;
  EXPECT_TRUE(ret);
};
Exemplo n.º 2
0
// Mainline case
TEST_F(DeregistrationTaskTest, MainlineTest)
{
  // Build the request
  std::string body = "{\"registrations\": [{\"primary-impu\": \"sip:6505550231@homedomain\", \"impi\": \"6505550231\"}]}";
  build_dereg_request(body);

  // Set up the regstore expectations
  std::string aor_id = "sip:6505550231@homedomain";
  // Get an initial empty AoR record and add a standard binding and subscription
  RegStore::AoR* aor = new RegStore::AoR(aor_id);
  int now = time(NULL);
  RegStore::AoR::Binding* b1 = aor->get_binding(std::string("<urn:uuid:00000000-0000-0000-0000-b4dd32817622>:1"));
  b1->_uri = std::string("<sip:[email protected]:59934;transport=tcp;ob>");
  b1->_cid = std::string("gfYHoZGaFaRNxhlV0WIwoS-f91NoJ2gq");
  b1->_cseq = 17038;
  b1->_expires = now + 300;
  b1->_priority = 0;
  b1->_path_headers.push_back(std::string("<sip:[email protected];lr>"));
  b1->_params["+sip.instance"] = "\"<urn:uuid:00000000-0000-0000-0000-b4dd32817622>\"";
  b1->_params["reg-id"] = "1";
  b1->_params["+sip.ice"] = "";
  b1->_emergency_registration = false;
  b1->_private_id = "6505550231";
  RegStore::AoR::Subscription* s1 = aor->get_subscription("1234");
  s1->_req_uri = std::string("sip:[email protected]:59934;transport=tcp");
  s1->_from_uri = std::string("<sip:[email protected]>");
  s1->_from_tag = std::string("4321");
  s1->_to_uri = std::string("<sip:[email protected]>");
  s1->_to_tag = std::string("1234");
  s1->_cid = std::string("[email protected]");
  s1->_route_uris.push_back(std::string("<sip:[email protected];lr>"));
  s1->_expires = now + 300;
  // Set up the remote store to return NULL
  RegStore::AoR* remote_aor = NULL;
  std::vector<std::string> aor_ids = {aor_id};
  std::vector<RegStore::AoR*> aors = {aor};
  expect_reg_store_updates(aor_ids, aors, remote_aor);

  // Run the task
  EXPECT_CALL(*_regstore, send_notify(s1, _, b1, _, _));
  EXPECT_CALL(*_httpstack, send_reply(_, 200, _));
  _task->run();
}