Esempio n. 1
0
 def test_session_connected(self):
     ApiSession.clear_cached_sessions()
     session = ApiSession(controller_ip=login_info["controller_ip"],
                          username=login_info.get("username", "admin"),
                          password=login_info.get("password", "fr3sca$%^"),
                          lazy_authentication=True)
     assert not session.connected
     session.get('pool')
     assert session.connected
     ApiSession.clear_cached_sessions()
     session = ApiSession(controller_ip=login_info["controller_ip"],
                          username=login_info.get("username", "admin"),
                          password=login_info.get("password", "fr3sca$%^"),
                          lazy_authentication=False)
     assert session.connected
Esempio n. 2
0
 def test_lazy_authentication(self):
     ApiSession.clear_cached_sessions()
     session = ApiSession(controller_ip=login_info["controller_ip"],
                          username=login_info.get("username", "admin"),
                          password=login_info.get("password", "avi123"),
                          lazy_authentication=True)
     assert not session.keystone_token
     session.get('pool')
     assert session.keystone_token
     ApiSession.clear_cached_sessions()
     session = ApiSession(controller_ip=login_info["controller_ip"],
                          username=login_info.get("username", "admin"),
                          password=login_info.get("password", "avi123"),
                          lazy_authentication=False)
     assert session.keystone_token
Esempio n. 3
0
    def test_context_sharing(self):
        api1 = ApiSession(controller_ip=login_info.get('controller_ip'),
                          username=login_info.get('username'),
                          password=login_info.get('password'),
                          lazy_authentication=False)

        context_api1 = api1.get_context()

        api1.clear_cached_sessions()

        api2 = ApiSession(controller_ip=login_info.get('controller_ip'),
                          username=login_info.get('username'),
                          password=login_info.get('password'),
                          session_id= context_api1['session_id'],
                          csrftoken=context_api1['csrftoken'],
                          lazy_authentication=True)
        api2.get('pool')
        assert api2.get_context() == context_api1
Esempio n. 4
0
    def test_user_login(self):
        api1 = ApiSession(controller_ip=login_info.get('controller_ip'),
                          username=login_info.get('username'),
                          password=login_info.get('password'),
                          lazy_authentication=False)
        user_info = gSAMPLE_CONFIG["Passwords"]
        original_password = login_info.get('password')
        new_password = "******"
        user_info['password'] = new_password
        user_info['old_password'] = original_password
        res = api1.put('useraccount', data=json.dumps(user_info))
        assert res.status_code == 200
        api1.clear_cached_sessions()

        api2 = ApiSession(controller_ip=login_info.get('controller_ip'),
                          username=login_info.get('username'),
                          password=new_password,
                          lazy_authentication=False)
        res = api2.get('pool')
        assert res.status_code in [200, 204]

        resp = api2.get('systemconfiguration', tenant='admin')
        r = resp.json()
        data = r['portal_configuration']['password_strength_check'] = False
        sysresp = api2.put('systemconfiguration', data=data, tenant='admin')
        assert sysresp.status_code == 200
        old_password = user_info['password']
        changed_password = original_password
        user_info['password'] = original_password
        user_info['old_password'] = old_password
        result = api2.put('useraccount', user_info)
        assert result.status_code == 200
        res = api2.get('pool')
        assert res.status_code in [200, 204]
        api2.clear_cached_sessions()

        api3 = ApiSession(controller_ip=login_info.get('controller_ip'),
                          username=login_info.get('username'),
                          password=changed_password,
                          lazy_authentication=False)
        res = api3.get('pool')
        assert res.status_code in [200, 204]