From 4101e6ada074af09e7bbb11cddf76374b28b25e8 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Thu, 4 Apr 2013 17:32:55 +0200 Subject: [PATCH] Test empty parameters on load. --- ngcp/dp.lua | 6 ++++++ ngcp/pp.lua | 8 ++++++-- ngcp/up.lua | 6 ++++++ tests/ngcp_dp.lua | 10 ++++++++++ tests/ngcp_pp.lua | 10 ++++++++++ tests/ngcp_rp.lua | 8 ++++++++ tests/ngcp_up.lua | 10 ++++++++++ 7 files changed, 56 insertions(+), 2 deletions(-) diff --git a/ngcp/dp.lua b/ngcp/dp.lua index 0dcd499..7505eb3 100644 --- a/ngcp/dp.lua +++ b/ngcp/dp.lua @@ -17,10 +17,16 @@ NGCPDomainPrefs_MT = { __index = NGCPDomainPrefs } end function NGCPDomainPrefs:caller_load(uuid) + if not uuid then + error("uuid is empty") + end return NGCPDomainPrefs._load(self,"caller",uuid) end function NGCPDomainPrefs:callee_load(uuid) + if not uuid then + error("uuid is empty") + end return NGCPDomainPrefs._load(self,"callee",uuid) end diff --git a/ngcp/pp.lua b/ngcp/pp.lua index cbd3c31..cecb488 100644 --- a/ngcp/pp.lua +++ b/ngcp/pp.lua @@ -17,11 +17,15 @@ NGCPPeerPrefs_MT = { __index = NGCPPeerPrefs } end function NGCPPeerPrefs:caller_load(uuid) - return self:_load("caller",uuid) + if uuid then + return self:_load("caller",uuid) + end end function NGCPPeerPrefs:callee_load(uuid) - return self:_load("callee",uuid) + if uuid then + return self:_load("callee",uuid) + end end function NGCPPeerPrefs:_load(level, uuid) diff --git a/ngcp/up.lua b/ngcp/up.lua index 2dc2a5e..91d4927 100644 --- a/ngcp/up.lua +++ b/ngcp/up.lua @@ -17,10 +17,16 @@ NGCPUserPrefs_MT = { __index = NGCPUserPrefs } end function NGCPUserPrefs:caller_load(uuid) + if not uuid then + error("uuid is empty") + end return NGCPUserPrefs._load(self,"caller",uuid) end function NGCPUserPrefs:callee_load(uuid) + if not uuid then + error("uuid is empty") + end return NGCPUserPrefs._load(self,"callee",uuid) end diff --git a/tests/ngcp_dp.lua b/tests/ngcp_dp.lua index 66c0d27..80a0c4a 100644 --- a/tests/ngcp_dp.lua +++ b/tests/ngcp_dp.lua @@ -70,6 +70,16 @@ TestNGCPDomainPrefs = {} --class assertEquals(self.d.db_table, "dom_preferences") end + function TestNGCPDomainPrefs:test_caller_load_empty() + assertTrue(self.d.config) + assertError(self.d.caller_load, nil) + end + + function TestNGCPDomainPrefs:test_callee_load_empty() + assertTrue(self.d.config) + assertError(self.d.callee_load, nil) + end + function TestNGCPDomainPrefs:test_caller_load() assertTrue(self.d.config) self.config:getDBConnection() ;mc :returns(self.con) diff --git a/tests/ngcp_pp.lua b/tests/ngcp_pp.lua index ce60b26..5e604e3 100644 --- a/tests/ngcp_pp.lua +++ b/tests/ngcp_pp.lua @@ -70,6 +70,16 @@ TestNGCPPeerPrefs = {} --class assertEquals(self.d.db_table, "peer_preferences") end + function TestNGCPPeerPrefs:test_caller_load_empty() + assertTrue(self.d.config) + assertEquals(self.d.caller_load(), nil) + end + + function TestNGCPPeerPrefs:test_callee_load_empty() + assertTrue(self.d.config) + assertEquals(self.d.callee_load(), nil) + end + function TestNGCPPeerPrefs:test_caller_load() assertTrue(self.d.config) self.config:getDBConnection() ;mc :returns(self.con) diff --git a/tests/ngcp_rp.lua b/tests/ngcp_rp.lua index c84fb3a..90d3ec6 100644 --- a/tests/ngcp_rp.lua +++ b/tests/ngcp_rp.lua @@ -57,6 +57,14 @@ TestNGCPRealPrefs = {} --class sr.log("info", "---cleaned---") end + function TestNGCPRealPrefs:test_caller_load_empty() + assertError(self.real.caller_load, nil) + end + + function TestNGCPRealPrefs:test_callee_load_empty() + assertError(self.real.callee_load, nil) + end + function TestNGCPRealPrefs:test_caller_load() local keys = {"uno"} local xavp = { diff --git a/tests/ngcp_up.lua b/tests/ngcp_up.lua index 7dd27de..767546f 100644 --- a/tests/ngcp_up.lua +++ b/tests/ngcp_up.lua @@ -65,6 +65,16 @@ TestNGCPUserPrefs = {} --class sr.log("info", "---cleaned---") end + function TestNGCPUserPrefs:test_caller_load_empty() + assertTrue(self.d.config) + assertError(self.d.caller_load, nil) + end + + function TestNGCPUserPrefs:test_callee_load_empty() + assertTrue(self.d.config) + assertError(self.d.callee_load, nil) + end + function TestNGCPUserPrefs:test_init() --print("TestNGCPUserPrefs:test_init") assertEquals(self.d.db_table, "usr_preferences")