Exemple #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);
};
Exemple #2
0
TYPED_TEST(BasicRegStoreTest, CopyTests)
{
  RegStore::AoR* aor_data1;
  RegStore::AoR::Binding* b1;
  RegStore::AoR::Subscription* s1;
  int now;

  // Get an initial empty AoR record.
  now = time(NULL);
  aor_data1 = this->_store->get_aor_data(std::string("*****@*****.**"), 0);
  ASSERT_TRUE(aor_data1 != NULL);
  EXPECT_EQ(0u, aor_data1->bindings().size());
  EXPECT_EQ(0u, aor_data1->subscriptions().size());

  // Add a binding to the record.
  b1 = aor_data1->get_binding(std::string("urn:uuid:00000000-0000-0000-0000-b4dd32817622:1"));
  EXPECT_EQ(1u, aor_data1->bindings().size());
  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->_timer_id = "00000000000";
  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->_private_id = "*****@*****.**";
  b1->_emergency_registration = false;

  // Add a subscription to the record.
  s1 = aor_data1->get_subscription("1234");
  EXPECT_EQ(1u, aor_data1->subscriptions().size());
  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 the NOTIFY CSeq value to 1.
  aor_data1->_notify_cseq = 1;

  // Test AoR copy constructor.
  RegStore::AoR* copy = new RegStore::AoR(*aor_data1);
  EXPECT_EQ(1u, copy->bindings().size());
  EXPECT_EQ(1u, copy->subscriptions().size());
  delete copy; copy = NULL;

  // Test AoR assignment.
  copy = new RegStore::AoR("sip:[email protected]");
  *copy = *aor_data1;
  EXPECT_EQ(1u, copy->bindings().size());
  EXPECT_EQ(1u, copy->subscriptions().size());
  delete copy; copy = NULL;
  delete aor_data1; aor_data1 = NULL;
}
// 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();
}