def test_impersonate(self):
        """ Start impersonate """

        controller = NURESTLoginController()
        controller.impersonate(user='******', enterprise='Google')

        self.assertEquals(controller.is_impersonating, True)
        self.assertEquals(controller.impersonation, 'Alex@Google')
    def test_get_authentication_header_as_string(self):
        """ Get authentication header as string """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = '******'
        controller.api_key = None

        self.assertEquals(controller.get_authentication_header() , 'XREST dXNlcm5hbWU6cGFzc3dvcmQ=')
    def test_get_authentication_header_with_api_key_param(self):
        """ Get authentication header with api key parameter """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = None
        controller.api_key = None

        self.assertEquals(controller.get_authentication_header(password='******') , 'XREST dXNlcm5hbWU6cGFzc3dvcmQ=')
    def test_get_authentication_header_with_api_key(self):
        """ Get authentication header with api key """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = '******'
        controller.api_key = '123456'

        self.assertEquals(controller.get_authentication_header() , 'XREST dXNlcm5hbWU6MTIzNDU2')
 def setUp(self):
     """ Set up the context """
     controller = NURESTLoginController()
     controller.user = '******'
     controller.password = '******'
     controller.url = 'http://www.google.fr'
     controller.api_key = '12345'
     controller.enterprise = 'Alcatel'
    def test_reset_login_controller(self):
        """ Reset login controller """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = '******'
        controller.url = 'http://www.google.fr'
        controller.api_key = '12345'
        controller.enterprise = 'Alcatel'

        controller.reset()

        self.assertEquals(controller.user, None)
        self.assertEquals(controller.password, None)
        self.assertEquals(controller.url, None)
        self.assertEquals(controller.enterprise, None)
        self.assertEquals(controller.api_key, None)
    def test_get_authentication_header_as_string(self):
        """ Get authentication header as string """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = '******'
        controller.api_key = None

        self.assertEquals(controller.get_authentication_header() , 'XREST dXNlcm5hbWU6cGFzc3dvcmQ=')
    def test_get_authentication_header_with_api_key_param(self):
        """ Get authentication header with api key parameter """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = None
        controller.api_key = None

        self.assertEquals(controller.get_authentication_header(password='******') , 'XREST dXNlcm5hbWU6cGFzc3dvcmQ=')
    def test_get_authentication_header_with_api_key(self):
        """ Get authentication header with api key """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = '******'
        controller.api_key = '123456'

        self.assertEquals(controller.get_authentication_header() , 'XREST dXNlcm5hbWU6MTIzNDU2')
    def test_stop_impersonate(self):
        """ Stop impersonate """
        controller = NURESTLoginController()
        controller.impersonate(user='******', enterprise='Google')
        self.assertEquals(controller.is_impersonating, True)

        controller.stop_impersonate()
        self.assertEquals(controller.is_impersonating, False)
        self.assertEquals(controller.impersonation, None)
    def test_login_controller_is_not_singleton(self):
        """ login controller is singleton """
        ctrl_a = NURESTLoginController()
        ctrl_a.user = '******'
        ctrl_b = NURESTLoginController()
        ctrl_b.user = '******'

        self.assertEquals(ctrl_a.user, 'Christophe')
        self.assertEquals(ctrl_b.user, 'Toto')
        self.assertNotEqual(ctrl_a, ctrl_b)
    def test_get_authentication_header_with_api_key(self):
        """ Get authentication header with api key """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = None
        controller.api_key = '12345ABCD'

        header = controller.get_authentication_header()
        self.assertEquals(header, 'XREST Y2hyaXN0b3BoZToxMjM0NUFCQ0Q=')
    def test_get_authentication_header_without_api_key(self):
        """ Get authentication header without api key """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = '******'
        controller.api_key = None

        header = controller.get_authentication_header()
        self.assertEquals(header, 'XREST Y2hyaXN0b3BoZTp0dUNyMElzS29pPw==')
Exemple #14
0
    def test_get_authentication_header_with_tilde(self):
        """ Get authentication header with tilde """

        controller = NURESTLoginController()
        controller.user = '******'
        controller.password = '******'
        controller.api_key = None

        self.assertEquals(controller.get_authentication_header(),
                          'XREST dXNlcm5hbWU6cH5hc3N+d29yfmQ=')
 def tearDown(self):
     """ Cleaning context """
     ctrl = NURESTLoginController()
     ctrl.reset()