def test_anonymous_service(self):
        # Not token needed, not user provided
        mock_user_io(self.user_io)
        ret = self.rest_client.get_cells_snapshot("blockversion")
        self.assertEqual(ret, "snapshot")

        # Login not stored
        self.assertEquals(self.localdb.set_login_call_counter, 0)
Beispiel #2
0
    def test_anonymous_service(self):
        # Not token needed, not user provided
        mock_user_io(self.user_io)
        ret = self.rest_client.get_cells_snapshot("blockversion")
        self.assertEqual(ret, "snapshot")

        # Login not stored
        self.assertEquals(self.localdb.set_login_call_counter, 0)
 def test_no_ide(self):
     settings = Settings()
     user_io = mocked_user_io()
     mock_user_io(user_io, {'username': '******',
                            'IP Address': '127.1.2.3',
                            'directory': 'mydir'})
     rpi_settings_wizard(user_io, settings)
     self.assertEqual(settings.rpi.directory, 'mydir')
     self.assertEqual(settings.rpi.ip, '127.1.2.3')
     self.assertEqual(settings.rpi.user, 'piuser')
Beispiel #4
0
    def test_one_retry(self):
        mock_user_io(self.user_io,
                     login=[("pepe", "badpass"), ("pepe", "goodpass")])

        self.assertEqual(self.restmanager.get_dep_table("blockversion"),
                         "dep_table")

        # Two attemps, first fails because None is returned as user, second with a real token
        self.assertEqual(self.rest_client.dep_table_call_counter, 2)

        # Login stored
        self.assertEquals(self.localdb.set_login_call_counter, 1)
Beispiel #5
0
    def test_all_retries(self):
        # user_io.request_login has to be called 3 times
        mock_user_io(self.user_io,
                     login=[("pepe", "badpass"), ("pepe", "badpass2"),
                            ("pepe", "badpass3")])
        self.assertRaises(AuthenticationException,
                          self.restmanager.get_dep_table, "blockversion")
        # Only one attemp to call get_dep_table, it raises all the rest in get_token
        self.assertEqual(self.rest_client.dep_table_call_counter, 1)

        # Login not stored
        self.assertEquals(self.localdb.set_login_call_counter, 0)
 def test_no_ide(self):
     settings = Settings()
     user_io = mocked_user_io()
     mock_user_io(user_io, {
         'username': '******',
         'IP Address': '127.1.2.3',
         'directory': 'mydir'
     })
     rpi_settings_wizard(user_io, settings)
     self.assertEqual(settings.rpi.directory, 'mydir')
     self.assertEqual(settings.rpi.ip, '127.1.2.3')
     self.assertEqual(settings.rpi.user, 'piuser')
    def test_one_retry(self):
        mock_user_io(self.user_io,
                     login=[("pepe", "badpass"),
                            ("pepe", "goodpass")])

        self.assertEqual(self.restmanager.get_dep_table("blockversion"), "dep_table")

        # Two attemps, first fails because None is returned as user, second with a real token
        self.assertEqual(self.rest_client.dep_table_call_counter, 2)

        # Login stored
        self.assertEquals(self.localdb.set_login_call_counter, 1)
    def test_all_retries(self):
        # user_io.request_login has to be called 3 times
        mock_user_io(self.user_io,
                     login=[("pepe", "badpass"),
                            ("pepe", "badpass2"),
                            ("pepe", "badpass3")])
        self.assertRaises(AuthenticationException, self.restmanager.get_dep_table, "blockversion")
        # Only one attemp to call get_dep_table, it raises all the rest in get_token
        self.assertEqual(self.rest_client.dep_table_call_counter, 1)

        # Login not stored
        self.assertEquals(self.localdb.set_login_call_counter, 0)
    def test_anonymous_call_with_necessary_login(self):
        # In localdb there are not credentials.
        # There will be two calls to get_dep_table:
        #   1. With an anonymous user: Will fail in server with a ForbiddenException
        #   2. Before request login and password to user, will call again with token
        mock_user_io(self.user_io, login=("pepe", "goodpass"))

        # Result is OK
        self.assertEqual(self.restmanager.get_dep_table("blockversion"), "dep_table")
        # Two calls to real api
        self.assertEqual(self.rest_client.dep_table_call_counter, 2)
        # Stored in localdb right credentials
        self.assertEquals(self.localdb.set_login_call_counter, 1)
        self.assertEquals(self.localdb.token, "goodtoken")

        # In user io must be the message Please log in to perform this action. If you don\'t have'
        # an account sign up here: http://www.biicode.com

        self.assertIn('Please log in to perform this action. If you don\'t have '
                      'an account sign up here: http://www.biicode.com', str(self.user_io))
Beispiel #10
0
    def test_anonymous_call_with_necessary_login(self):
        # In localdb there are not credentials.
        # There will be two calls to get_dep_table:
        #   1. With an anonymous user: Will fail in server with a ForbiddenException
        #   2. Before request login and password to user, will call again with token
        mock_user_io(self.user_io, login=("pepe", "goodpass"))

        # Result is OK
        self.assertEqual(self.restmanager.get_dep_table("blockversion"),
                         "dep_table")
        # Two calls to real api
        self.assertEqual(self.rest_client.dep_table_call_counter, 2)
        # Stored in localdb right credentials
        self.assertEquals(self.localdb.set_login_call_counter, 1)
        self.assertEquals(self.localdb.token, "goodtoken")

        # In user io must be the message Please log in to perform this action. If you don\'t have'
        # an account sign up here: http://www.biicode.com

        self.assertIn(
            'Please log in to perform this action. If you don\'t have '
            'an account sign up here: http://www.biicode.com',
            str(self.user_io))