Esempio n. 1
0
        def test_extensible_login(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14123)
            self.rfs.start()
            try:
                wds = LoginWebLabDeustoSOAP("http://localhost:14123/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                SYSTEM = "facebook"
                CREDENTIALS = "(my credentials)"
                MESSAGE = "my message"

                self.mock_server.return_values["login_based_on_other_credentials"] = expected_sess_id

                session = wds.login_based_on_other_credentials(SYSTEM, CREDENTIALS)
                self.assertEquals(expected_sess_id.id, session.id)

                self.assertEquals(SYSTEM, self.mock_server.arguments["login_based_on_other_credentials"][0])
                self.assertEquals(CREDENTIALS, self.mock_server.arguments["login_based_on_other_credentials"][1])

                self.mock_server.exceptions["login_based_on_other_credentials"] = LoginErrors.InvalidCredentialsError(
                    MESSAGE
                )

                try:
                    wds.login_based_on_other_credentials(SYSTEM, CREDENTIALS)
                    self.fail("exception expected")
                except ZSI.FaultException as e:
                    self.assertEquals(LoginRFCodes.CLIENT_INVALID_CREDENTIALS_EXCEPTION_CODE, e.fault.code[1])
                    self.assertEquals(MESSAGE, e.fault.string)
            finally:
                self.rfs.stop()
Esempio n. 2
0
        def test_login(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14122)
            self.rfs.start()
            try:
                wds = LoginWebLabDeustoSOAP("http://localhost:14122/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                USERNAME = "******"
                PASSWORD = "******"
                MESSAGE = "my message"

                self.mock_server.return_values["login"] = expected_sess_id

                session = wds.login(USERNAME, PASSWORD)
                self.assertEquals(expected_sess_id.id, session.id)

                self.assertEquals(USERNAME, self.mock_server.arguments["login"][0])
                self.assertEquals(PASSWORD, self.mock_server.arguments["login"][1])

                self.mock_server.exceptions["login"] = LoginErrors.InvalidCredentialsError(MESSAGE)

                try:
                    wds.login(USERNAME, PASSWORD)
                    self.fail("exception expected")
                except ZSI.FaultException as e:
                    self.assertEquals(LoginRFCodes.CLIENT_INVALID_CREDENTIALS_EXCEPTION_CODE, e.fault.code[1])
                    self.assertEquals(MESSAGE, e.fault.string)
            finally:
                self.rfs.stop()
        def test_extensible_login(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT,
                                                 14123)
            self.rfs.start()
            try:
                wds = LoginWebLabDeustoSOAP(
                    "http://localhost:14123/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                SYSTEM = 'facebook'
                CREDENTIALS = '(my credentials)'
                MESSAGE = 'my message'

                self.mock_server.return_values[
                    'login_based_on_other_credentials'] = expected_sess_id

                session = wds.login_based_on_other_credentials(
                    SYSTEM, CREDENTIALS)
                self.assertEquals(expected_sess_id.id, session.id)

                self.assertEquals(
                    SYSTEM, self.mock_server.
                    arguments['login_based_on_other_credentials'][0])
                self.assertEquals(
                    CREDENTIALS, self.mock_server.
                    arguments['login_based_on_other_credentials'][1])

                self.mock_server.exceptions[
                    'login_based_on_other_credentials'] = LoginErrors.InvalidCredentialsError(
                        MESSAGE)

                try:
                    wds.login_based_on_other_credentials(SYSTEM, CREDENTIALS)
                    self.fail('exception expected')
                except ZSI.FaultException as e:
                    self.assertEquals(
                        LoginRFCodes.CLIENT_INVALID_CREDENTIALS_EXCEPTION_CODE,
                        e.fault.code[1])
                    self.assertEquals(MESSAGE, e.fault.string)
            finally:
                self.rfs.stop()
        def test_login(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT,
                                                 14122)
            self.rfs.start()
            try:
                wds = LoginWebLabDeustoSOAP(
                    "http://localhost:14122/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                USERNAME = '******'
                PASSWORD = '******'
                MESSAGE = 'my message'

                self.mock_server.return_values['login'] = expected_sess_id

                session = wds.login(USERNAME, PASSWORD)
                self.assertEquals(expected_sess_id.id, session.id)

                self.assertEquals(USERNAME,
                                  self.mock_server.arguments['login'][0])
                self.assertEquals(PASSWORD,
                                  self.mock_server.arguments['login'][1])

                self.mock_server.exceptions[
                    'login'] = LoginErrors.InvalidCredentialsError(MESSAGE)

                try:
                    wds.login(USERNAME, PASSWORD)
                    self.fail('exception expected')
                except ZSI.FaultException as e:
                    self.assertEquals(
                        LoginRFCodes.CLIENT_INVALID_CREDENTIALS_EXCEPTION_CODE,
                        e.fault.code[1])
                    self.assertEquals(MESSAGE, e.fault.string)
            finally:
                self.rfs.stop()