Commit 5bccf916 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia
Browse files

(MERGE) core/branches/02_00_00 [168951:169190]


git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/core/trunk@169195 ae0415b3-e90b-0410-900d-d0be9363c56b
parents 82326d85 8922c3ee
......@@ -610,6 +610,40 @@ return OpenBusFixture{
-- assert no notifications have arrived
checks.assert(observer:_get("offerRegistered"), checks.equal(nil))
end,
UnauthorizedObserverRemoval = function (fixture, openbus)
-- create observer
local context = openbus.context
local observer = newObserver({ offerRegistered = true }, context)
-- subscribe observer
local offers = fixture.offers
local newprops = { SomeOfferProps[1] }
local subscription = offers:subscribeObserver(observer, newprops)
local owner = context:getCurrentConnection().login
checks.assert(subscription, isOfferRegSubscription(owner,
observer,
newprops))
local system = fixture:newConn("system")
context:setCurrentConnection(system)
-- attempt to remove observer
local ok, err = pcall(subscription.remove, subscription)
checks.assert(ok, checks.equal(false))
checks.assert(err, checks.like{ _repid = UnauthorizedOperation })
-- change service offer properties
local comp = fixture.component
local offer = offers:registerService(comp.IComponent, SomeOfferProps)
context:setCurrentConnection(nil)
-- wait for observer notification
local desc = observer:_wait("offerRegistered")
checks.assert(desc, isServiceOfferDesc(comp, system.login, SomeOfferProps))
-- unsubscribe observer
subscription:remove()
-- change service offer properties to the watched properties
context:setCurrentConnection(system)
offer:setProperties(SomeOfferProps)
context:setCurrentConnection(nil)
-- assert no notifications have arrived
checks.assert(observer:_get("offerRegistered"), checks.equal(nil))
end,
},
},
AsSystem = OffersFixture{
......@@ -993,6 +1027,40 @@ return OpenBusFixture{
checks.assert(observer:_get("removed"), checks.equal(nil))
checks.assert(observer:_get("propertiesChanged"), checks.equal(nil))
end,
UnauthorizedObserverRemoval = function (fixture, openbus)
-- create observer
local context = openbus.context
local observer = newObserver({
propertiesChanged = true,
removed = true,
}, context)
-- subscribe observer
local offer = fixture.offer
local comp = fixture.component
local system = fixture.system
local login = system.login
local subscription = offer:subscribeObserver(observer)
local owner = context:getCurrentConnection().login
checks.assert(subscription, isOfferSubscription(owner,
observer,
comp,
login,
SomeOfferProps))
-- attempt to remove observer as other entity
context:setCurrentConnection(system)
local ok, err = pcall(subscription.remove, subscription)
checks.assert(ok, checks.equal(false))
checks.assert(err, checks.like{ _repid = UnauthorizedOperation })
-- remove service offer
offer:remove()
context:setCurrentConnection(nil)
-- wait for observer notification
local desc = observer:_wait("removed")
-- assert the notification is correct
checks.assert(desc, isServiceOfferDesc(comp, login, SomeOfferProps))
-- assert no other notification has arrived
checks.assert(observer:_get("propertiesChanged"), checks.equal(nil))
end,
},
},
},
......
#!/bin/bash
mode=$1
if [[ "$mode" == "" ]]; then
mode=RELEASE
elif [[ "$mode" != "RELEASE" && "$mode" != "DEBUG" ]]; then
echo "Usage: $0 [RELEASE|DEBUG]"
exit 1
fi
runbus="source ${OPENBUS_CORE_TEST}/runbus.sh $mode"
runadmin="source ${OPENBUS_CORE_TEST}/runadmin.sh $mode"
runtests="env OPENBUS_SDKLUA_HOME=${OPENBUS_LEGACYSDKLUA_HOME} OPENBUS_SDKLUA_TEST=${OPENBUS_LEGACYSDKLUA_TEST} /bin/bash runtests.sh $mode"
busport=21208
leasetime=6
passwordpenalty=6
export OPENBUS_TESTCFG=$OPENBUS_TEMP/test.properties
echo "bus.host.port=$busport" > $OPENBUS_TESTCFG
echo "login.lease.time=$leasetime" >> $OPENBUS_TESTCFG
echo "password.penalty.time=$passwordpenalty" >> $OPENBUS_TESTCFG
#echo "openbus.test.verbose=yes" >> $OPENBUS_TESTCFG
$runbus BUS01 $busport
genkey $OPENBUS_TEMP/testsyst
$runadmin localhost $busport --script=test.adm
$runtests OpenBus.LoginRegistry
$runtests OpenBus.OfferRegistry
$runadmin localhost $busport --undo-script=test.adm
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