Commit 1b17f8b4 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia
Browse files

[OPENBUS-2008] (Lua) Trocar operação 'AccessControl::getValidity(LoginIdSeq)'...

[OPENBUS-2008] (Lua) Trocar operação 'AccessControl::getValidity(LoginIdSeq)' por 'AccessControl::getLoginValidity(LoginId)'
- Também correções de pequenos bugs.


git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/core/trunk@132729 ae0415b3-e90b-0410-900d-d0be9363c56b
parent 9e979b2f
......@@ -288,7 +288,7 @@ const unsigned long UnknownBusCode;
\end{samplecode}
Em seguida, é necessário verificar se o login informado é válido no barramento indicado.
Isso é feito através da operação \code{getValidity} da \term{Faceta de Registro de Logins} do barramento.
Isso é feito através da operação \code{getLoginValidity} da \term{Faceta de Registro de Logins} do barramento.
O nome desta faceta é dado pela seguinte constante:
\begin{samplecode}[language={[CORBA]idl}]
......
......@@ -553,32 +553,23 @@ function LoginRegistry:getLoginInfo(id)
throw.InvalidLogins{loginIds={id}}
end
function LoginRegistry:getValidity(ids)
local logins = AccessControl.activeLogins
local now = time()
local validity = {}
for index, id in ipairs(ids) do
local login = logins:getLogin(id)
if login ~= nil then
local timeleft = login.deadline-now
if timeleft <= 0 then
log:action(msg.LoginExpired:tag{
login = login.id,
entity = login.entity,
})
login:remove()
timeleft = 0
else
timeleft = ceil(timeleft)
end
validity[index] = timeleft
elseif id == AccessControl.login.id then
validity[index] = AccessControl.leaseTime
else
validity[index] = 0
function LoginRegistry:getLoginValidity(id)
if id == AccessControl.login.id then
return AccessControl.leaseTime
end
local login = AccessControl.activeLogins:getLogin(id)
if login ~= nil then
local timeleft = login.deadline-time()
if timeleft > 0 then
return ceil(timeleft)
end
log:action(msg.LoginExpired:tag{
login = login.id,
entity = login.entity,
})
login:remove()
end
return validity
return 0
end
function LoginRegistry:subscribeObserver(callback)
......
......@@ -65,7 +65,7 @@ end
-- function LoginRegistry:getEntityLogins(entity)
-- function LoginRegistry:invalidateLogin(id)
-- function LoginRegistry:getLoginInfo(id)
-- function LoginRegistry:getValidity(ids)
-- function LoginRegistry:getLoginValidity(id)
-- function LoginRegistry:subscribeObserver(callback)
-------------------------------------
......@@ -157,19 +157,9 @@ end
function InvalidParamCase.testGetValidity(self)
local logins = self.logins
local list = { self.invalidId }
local ok, vals = pcall(logins.getValidity, logins, list)
local ok, validity = pcall(logins.getLoginValidity, logins, self.invalidId)
Check.assertTrue(ok)
Check.assertEquals(1, #vals)
Check.assertEquals(0, vals[1])
end
function InvalidParamCase.testGetValidityEmptyList(self)
local logins = self.logins
local list = {}
local ok, vals = pcall(logins.getValidity, logins, list)
Check.assertTrue(ok)
Check.assertEquals(0, #vals)
Check.assertEquals(0, validity)
end
function InvalidParamCase.testSubscribeInvalidObserver(self)
......@@ -292,11 +282,7 @@ function LRCase.testInvalidateLogin(self)
Check.assertNotNil(info)
Check.assertEquals(conn2.login.id, info.id)
Check.assertEquals(dUser, info.entity)
local list = { conn2.login.id }
local vals = logins:getValidity(list)
Check.assertNotNil(vals)
Check.assertEquals(1, #vals)
local validity = vals[1]
local validity = logins:getLoginValidity(conn2.login.id)
-- invalidating
local bool = logins:invalidateLogin(conn2.login.id)
Check.assertTrue(bool)
......@@ -337,11 +323,8 @@ end
function LRCase.testGetValidity(self)
local logins = self.logins
local list = { self.conn.login.id }
local vals = logins:getValidity(list)
Check.assertNotNil(vals)
Check.assertEquals(1, #vals)
Check.assertTrue(vals[1] > 0)
local validity = logins:getLoginValidity(self.conn.login.id)
Check.assertTrue(validity > 0)
end
function LRCase.test2ConnectionsGetValidity(self)
......@@ -349,12 +332,8 @@ function LRCase.test2ConnectionsGetValidity(self)
local conn2 = OpenBusContext:createConnection(host, port, connprops)
self.conn2 = conn2
conn2:loginByPassword(dUser, dPassword)
local list = { self.conn.login.id, conn2.login.id }
local vals = logins:getValidity(list)
Check.assertNotNil(vals)
Check.assertEquals(2, #vals)
Check.assertTrue(vals[1] > 0)
Check.assertTrue(vals[2] > 0)
local validity = logins:getLoginValidity(conn2.login.id)
Check.assertTrue(validity > 0)
end
function LRCase.testSubscribeObserver(self)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment