Beispiel #1
0
import os

import cobra
import cobra.unittests as c_unittests
import cobra.auth.shadowfile as c_auth_shadow


def shadowauth():

    testobj = c_unittests.TestObject()

    daemon = cobra.CobraDaemon(port=60602)
    shadowfile = os.path.join(os.path.dirname(__file__), 'shadowpass.txt')
    authmod = c_auth_shadow.ShadowFileAuth(shadowfile)
    daemon.setAuthModule(authmod)

    daemon.fireThread()

    objname = daemon.shareObject(testobj)

    # Now lets succeed
    authinfo = {'user': '******', 'passwd': 'secret'}
    t = cobra.CobraProxy('cobra://localhost:60602/%s' % objname,
                         authinfo=authinfo)
    c_unittests.accessTestObject(t)
    assert (t.getUser() == 'invisigoth')


c_unittests.addUnitTest(shadowauth)
Beispiel #2
0
import cobra
import cobra.unittests as c_unittests

def reftest():

    testobj = c_unittests.TestObject()

    daemon = cobra.CobraDaemon(port=60660)
    objname = daemon.shareObject( testobj, doref=True )
    daemon.fireThread()

    with cobra.CobraProxy('cobra://localhost:60660/%s' % objname) as t:
        c_unittests.accessTestObject( t )

    assert( daemon.getSharedObject( objname ) == None )

c_unittests.addUnitTest( reftest )
Beispiel #3
0
import os

import cobra
import cobra.unittests as c_unittests
import cobra.auth.shadowfile as c_auth_shadow


def shadowauth():

    testobj = c_unittests.TestObject()

    daemon = cobra.CobraDaemon(port=60602)
    shadowfile = os.path.join(os.path.dirname(__file__), "shadowpass.txt")
    authmod = c_auth_shadow.ShadowFileAuth(shadowfile)
    daemon.setAuthModule(authmod)

    daemon.fireThread()

    objname = daemon.shareObject(testobj)

    # Now lets succeed
    authinfo = {"user": "******", "passwd": "secret"}
    t = cobra.CobraProxy("cobra://localhost:60602/%s" % objname, authinfo=authinfo)
    c_unittests.accessTestObject(t)
    assert t.getUser() == "invisigoth"


c_unittests.addUnitTest(shadowauth)
Beispiel #4
0
    testobj = c_unittests.TestObject()

    daemon = cobra.CobraDaemon(port=60601)
    daemon.setAuthModule(c_auth.CobraAuthenticator())
    daemon.fireThread()

    objname = daemon.shareObject(testobj)

    # Lets fail because of no-auth first
    try:
        p = cobra.CobraProxy("cobra://localhost:60601/%s" % objname)
        raise Exception("Allowed un-authd connection!")
    except cobra.CobraAuthException, e:
        pass

    # Now fail with wrong auth
    try:
        p = cobra.CobraProxy("cobra://localhost:60601/%s" % objname, authinfo={})
        raise Exception("Allowed bad-auth connection!")
    except cobra.CobraAuthException, e:
        pass

    # Now lets succeed
    authinfo = {"user": "******", "passwd": "secret"}
    t = cobra.CobraProxy("cobra://localhost:60601/%s" % objname, authinfo=authinfo)
    c_unittests.accessTestObject(t)


c_unittests.addUnitTest(authtest)
Beispiel #5
0
import cobra
import cobra.unittests as c_unittests

def msgpacktest():

    testobj = c_unittests.TestObject()

    daemon = cobra.CobraDaemon(port=60610, msgpack=True)
    objname = daemon.shareObject( testobj )
    daemon.fireThread()

    t = cobra.CobraProxy('cobra://localhost:60610/%s?msgpack=1' % objname)
    c_unittests.accessTestObject( t )

c_unittests.addUnitTest( msgpacktest )
Beispiel #6
0
import cobra
import cobra.unittests as c_unittests

def basictest():

    testobj = c_unittests.TestObject()

    daemon = cobra.CobraDaemon(port=60600)
    objname = daemon.shareObject( testobj )
    daemon.fireThread()

    t = cobra.CobraProxy('cobra://localhost:60600/%s' % objname)
    c_unittests.accessTestObject( t )

c_unittests.addUnitTest( basictest )

Beispiel #7
0
import cobra
import cobra.unittests as c_unittests


def reftest():

    testobj = c_unittests.TestObject()

    daemon = cobra.CobraDaemon(port=60660)
    objname = daemon.shareObject(testobj, doref=True)
    daemon.fireThread()

    with cobra.CobraProxy('cobra://localhost:60660/%s' % objname) as t:
        c_unittests.accessTestObject(t)

    assert (daemon.getSharedObject(objname) == None)


c_unittests.addUnitTest(reftest)