def test_LoginRequest_requestargs(self): expected = { 'headers': { 'Cookie': 'APIC-cookie=None' }, 'allow_redirects': False, 'data': '{"aaaUser": {"attributes": ' + '{"name": "admin", "pwd": "password"}}}', 'timeout': 90, 'verify': False } session = LoginSession('http://1.1.1.1', 'admin', 'password') lr = LoginRequest('admin', 'password') assert lr.requestargs(session) == expected
def test_LoginRequest_individual_properties(self, user, password, prop): lr = LoginRequest(user, password) if prop == 'user': assert lr.user == user elif prop == 'password': assert lr.password == password else: raise NotImplementedError("Unexpected property name")
def login(self): """Login in to the remote server (APIC or Fabric Node). Raises: LoginError: If there was an error during login or the response could not be parsed. """ loginRequest = LoginRequest(self.user, self.password) try: rsp = self._accessimpl.post(loginRequest) except RestError as ex: self._parseResponse(ex.reason) self._parseResponse(rsp)
def test_LoginRequest_getUrl(self, sessionUrl): session = LoginSession(sessionUrl, 'admin', 'password') expected = sessionUrl + '/api/aaaLogin.json' lr = LoginRequest('admin', 'password') assert lr.getUrl(session) == expected
def test_LoginRequest_init(self): assert isinstance(LoginRequest('user', 'password'), LoginRequest)