Exemple #1
0
    def test_constructor(self):
        Server.reset()
        # Create object with alias
        Server(host=u'example.com', port=4064, server=u'ome')

        # Create object without alias
        Server(host=u'example2.com', port=4065)

        # without any params
        try:
            Server()
        except TypeError as te:
            assert str(te) == ("__new__() takes at least 3 arguments"
                               " (1 given)")
Exemple #2
0
def forgotten_password(request, **kwargs):
    request.session.modified = True

    template = "webadmin/forgotten_password.html"

    conn = None
    error = None
    blitz = None

    if request.method == 'POST':
        form = ForgottonPasswordForm(data=request.REQUEST.copy())
        if form.is_valid():
            blitz = Server.get(pk=request.REQUEST.get('server'))
            try:
                conn = getGuestConnection(blitz.host, blitz.port)
                if not conn.isForgottenPasswordSet():
                    error = "This server cannot reset password. Please contact your administrator."
                    conn = None
            except Exception, x:
                logger.error(traceback.format_exc())
                error = "Internal server error, please contact administrator."

            if conn is not None:
                try:
                    conn.reportForgottenPassword(
                        smart_str(request.REQUEST.get('username')),
                        smart_str(request.REQUEST.get('email')))
                    error = "Password was reseted. Check you mailbox."
                    form = None
                except Exception, x:
                    logger.error(traceback.format_exc())
                    error = "Internal server error, please contact administrator."
Exemple #3
0
def forgotten_password(request, **kwargs):
    request.session.modified = True
    
    template = "webadmin/forgotten_password.html"
    
    conn = None
    error = None
    blitz = None
    
    if request.method == 'POST':
        form = ForgottonPasswordForm(data=request.REQUEST.copy())
        if form.is_valid():
            blitz = Server.get(pk=request.REQUEST.get('server'))
            try:
                conn = getGuestConnection(blitz.host, blitz.port)
                if not conn.isForgottenPasswordSet():
                    error = "This server cannot reset password. Please contact your administrator."
                    conn = None
            except Exception, x:
                logger.error(traceback.format_exc())
                error = "Internal server error, please contact administrator."
        
            if conn is not None:
                try:
                    conn.reportForgottenPassword(smart_str(request.REQUEST.get('username')), smart_str(request.REQUEST.get('email')))
                    error = "Password was reseted. Check you mailbox."
                    form = None
                except Exception, x:
                    logger.error(traceback.format_exc())
                    error = "Internal server error, please contact administrator."
Exemple #4
0
    def test_constructor(self):
        Server.reset()
        # Create object with alias
        Server(host="example.com", port=4064, server="ome")

        # Create object without alias
        Server(host="example2.com", port=4065)

        # without any params
        try:
            Server()
        except TypeError as te:
            found = str(te)
            python2 = "__new__() takes at least 3 arguments (1 given)"
            python3 = ("__new__() missing 2 required positional arguments:"
                       " 'host' and 'port'")
            assert found in (python2, python3)
Exemple #5
0
    def test_get_and_find(self):
        Server.reset()

        SERVER_LIST = [[u'example1.com', 4064, u'omero1'],
                       [u'example2.com', 4064, u'omero2'],
                       [u'example3.com', 4064], [u'example4.com', 4064]]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)

        s1 = Server.get(1)
        assert s1.host == u'example1.com'
        assert s1.port == 4064
        assert s1.server == u'omero1'

        s2 = Server.find('example2.com')[0]
        assert s2.host == u'example2.com'
        assert s2.port == 4064
        assert s2.server == u'omero2'
Exemple #6
0
    def test_get_and_find(self):
        Server.reset()

        SERVER_LIST = [
            ["example1.com", 4064, "omero1"],
            ["example2.com", 4064, "omero2"],
            ["example3.com", 4064],
            ["example4.com", 4064],
        ]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)

        s1 = Server.get(1)
        assert s1.host == "example1.com"
        assert s1.port == 4064
        assert s1.server == "omero1"

        s2 = Server.find("example2.com")[0]
        assert s2.host == "example2.com"
        assert s2.port == 4064
        assert s2.server == "omero2"
 def setUp(self):
     super(AdminTests, self).setUp()
     
     c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
     try:
         root_password = c.ic.getProperties().getProperty('omero.rootpass')
         omero_host = c.ic.getProperties().getProperty('omero.host')
     finally:
         c.__del__()
     
     from omeroweb.connector import Server
     server_id = Server.find(server_host=omero_host)[0].id
     self.login('root', root_password, server_id)
 def setUp(self):
     super(AdminTests, self).setUp()
     
     c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
     try:
         root_password = c.ic.getProperties().getProperty('omero.rootpass')
         omero_host = c.ic.getProperties().getProperty('omero.host')
     finally:
         c.__del__()
     
     from omeroweb.connector import Server
     server_id = Server.find(server_host=omero_host)[0].id
     self.login('root', root_password, server_id)
Exemple #9
0
    def test_load_server_list(self):
        Server.reset()

        SERVER_LIST = [[u'example1.com', 4064, u'omero1'],
                       [u'example2.com', 4064, u'omero2'],
                       [u'example3.com', 4064], [u'example4.com', 4064]]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)
        Server.freeze()

        try:
            Server(host=u'example5.com', port=4064)
        except TypeError as te:
            assert str(te) == 'No more instances allowed'

        Server(host=u'example1.com', port=4064)
Exemple #10
0
def forgotten_password(request, **kwargs):
    request.session.modified = True
    
    template = "webadmin/forgotten_password.html"
    
    conn = None
    error = None
    blitz = None

    def getGuestConnection(host, port):
        server_id = request.session['connector'].server_id
        return Connector(server_id, True).create_guest_connection('OMERO.web')

    if request.method == 'POST':
        form = ForgottonPasswordForm(data=request.REQUEST.copy())
        if form.is_valid():
            blitz = Server.get(pk=request.REQUEST.get('server'))
            try:
                conn = getGuestConnection(blitz.host, blitz.port)
                if not conn.isForgottenPasswordSet():
                    error = "This server cannot reset password. Please contact your administrator."
                    conn = None
            except Exception:
                logger.error(traceback.format_exc())
                error = "Internal server error, please contact administrator."
        
            if conn is not None:
                try:
                    conn.reportForgottenPassword(smart_str(request.REQUEST.get('username')), smart_str(request.REQUEST.get('email')))
                    error = "Password was reset. Check your mailbox."
                    form = None
                except Exception:
                    logger.error(traceback.format_exc())
                    error = "Internal server error, please contact administrator."
    else:
        form = ForgottonPasswordForm()
    
    context = {'error':error, 'form':form}    
    t = template_loader.get_template(template)
    c = Context(request, context)
    rsp = t.render(c)
    return HttpResponse(rsp)