Пример #1
0
 def test_mail_valid_args(self):
     add_user2()
     self.login(email2, password2)
     with app.app_context():
         self.assertRedirect(
             self.app.get(url_for('bs.mail', character_id=123,
                                  mail_id=456)), url_for('bs.dashboard'))
Пример #2
0
 def test_unknown_character_id(self):
     add_user2()
     self.login(email2, password2)
     with app.app_context():
         self.assertRedirect(
             self.app.get(url_for('bs.character', character_id=123)),
             url_for('bs.index'))
Пример #3
0
 def login(self, email, password, target=None):
     with app.app_context():
         url = url_for('bs.login')
         if target:
             url += '?next=' + target
         data = dict(email=email, password=password)
         return self.app.post(url, data=data, follow_redirects=True)
Пример #4
0
 def test_mail_known_user_past(self):
     self.login(email, password)
     with app.app_context():
         self.assertRedirect(
             self.app.get(
                 url_for('bs.mail', character_id=character_id,
                         mail_id=123)), url_for('bs.index'))
Пример #5
0
 def test_maillist_foreign_id(self):
     # EVE character ID which does not belong to the active user.
     add_user2()
     self.login(email2, password2)
     with app.app_context():
         self.assertRedirect(
             self.app.get(url_for('bs.maillist', character_id=chribba_id)),
             url_for('bs.dashboard'))
Пример #6
0
 def test_mail_known_user_future(self):
     add_user3()
     self.login(email3, password3)
     with app.app_context():
         self.assertRedirect(
             self.app.get(
                 url_for('bs.mail', character_id=character_id,
                         mail_id=123)), url_for('bs.dashboard'))
Пример #7
0
 def test_remove_char_owner_mismatch(self):
     add_user3()
     self.login(email3, password3)
     with app.app_context():
         self.assertRedirect(
             self.app.get(
                 url_for('bs.rmcharacter', character_id=character_id)),
             url_for('bs.dashboard'))
Пример #8
0
 def test_activate_valid(self):
     add_user4()
     with app.app_context():
         self.assertRedirect(
             self.app.get(
                 url_for('bs.activate',
                         email=email4,
                         token=activation_token)), url_for('bs.login'))
Пример #9
0
 def test_callback(self):
     suffix = '?code=79ZuSjgpQQ34nVQUTqw1RpZMshfdK320q9Hdzh23UijlpLiMqjc-8ZRN7drWuFIF0'
     eml = self.new_user(password)
     self.login(eml, password)
     with app.app_context():
         resp = self.app.get(url_for('sso.callback') + suffix,
                             follow_redirects=True)
     self.assertTrue(b'Error obtaining authentication token' in resp.data)
Пример #10
0
def add_user2():
    with app.app_context():
        user = User()
        user.email = email2
        user.password = password2
        user.level = UserLevel.DEFAULT
        user.insert()
        return user
Пример #11
0
def add_user4():
    with app.app_context():
        user = User()
        user.email = email4
        user.password = '******'
        user.activation_token = activation_token
        user.level = UserLevel.REGISTERED
        user.insert()
        return user
Пример #12
0
 def test_eve_char_valid_ids(self):
     ids = set([chribba_id, eulynn_id])
     with app.app_context():
         self.inCache.eve_characters(ids)  # populate cache
         cs = self.inCache.eve_characters(ids)
         self.assertEqual(len(ids), len(cs))
         while cs:
             c = cs.pop()
             if c.eve_id == chribba_id:
                 self.assertEqual(c.name, 'Chribba')
             elif c.eve_id == eulynn_id:
                 self.assertEqual(c.name, 'Eulynn')
             else:
                 self.fail(f'Unexpected ID {c.eve_id}')
Пример #13
0
def add_user3():
    with app.app_context():
        user = User()
        user.email = email3
        user.password = password3
        user.level = UserLevel.ADMIN

        character = Character()
        character.eve_id = character_id3
        character.name = character_name3
        character.token = json.dumps({
            'access_token': 'foo',
            'expires_at': time.time() - 600,  # Expired 10 minutes ago
            'refresh_token': 'bar'
        })
        user.characters = [character]
        user.insert()
        return user
Пример #14
0
    def setUp(self):
        warnings.filterwarnings('ignore',
                                message='unclosed <ssl\.SSLSocket ',
                                category=ResourceWarning)
        warnings.filterwarnings(
            'ignore',
            message='The psycopg2 wheel package will be renamed ',
            category=UserWarning)
        warnings.filterwarnings('ignore',
                                message='update is deprecated.',
                                category=DeprecationWarning)
        warnings.filterwarnings('ignore',
                                message='save is deprecated.',
                                category=DeprecationWarning)
        warnings.filterwarnings('ignore',
                                message='remove is deprecated.',
                                category=DeprecationWarning)
        app.config.from_object('bootini_star.config.Testing')
        self.app = app.test_client()
        with app.app_context():
            user = User(ensure_indexes=True)
            user.email = email
            user.password = password
            user.level = UserLevel.DEFAULT

            character = Character()
            character.eve_id = character_id
            character.name = character_name
            character.token = {
                'access_token': 'foo',
                'expires_at': time.time() + 600,  # Expires in 10 minutes
                'refresh_token': 'bar'
            }

            user.characters = [character]
            self.assertIsNotNone(user.insert())
Пример #15
0
 def signup(self, eml, pw, confirm=''):
     data = dict(email=eml, password=pw, confirm=confirm)
     with app.app_context():
         return self.app.post(url_for('bs.signup'),
                              data=data,
                              follow_redirects=True)
Пример #16
0
 def pwchange(self, current, pw, confirm=''):
     data = dict(current=current, password=pw, confirm=confirm)
     with app.app_context():
         return self.app.post(url_for('bs.password'),
                              data=data,
                              follow_redirects=True)
Пример #17
0
 def test_admin_unauthorised(self):
     self.login(email, password)
     with app.app_context():
         self.assertRedirect(self.app.get(url_for('bs.admin')),
                             url_for('bs.login'))
Пример #18
0
 def test_admin_valid(self):
     add_user3()
     self.login(email3, password3)
     with app.app_context():
         resp = self.app.get(url_for('bs.admin'))
         self.assertSubstr(CREATE_INDEXES, resp)
Пример #19
0
 def test_good_character_id(self):
     add_user2()
     self.login(email2, password2)
     with app.app_context():
         resp = self.app.get(url_for('bs.character', character_id=93779241))
     self.assertTrue(b'Gallente Citizen 93779241' in resp.data)
Пример #20
0
 def test_load_unknown_user(self):
     with app.app_context():
         self.assertIsNone(user_loader(email2))
Пример #21
0
 def test_activate_unknown_token(self):
     add_user4()
     with app.app_context():
         self.assertRedirect(
             self.app.get(url_for('bs.activate', email=email4,
                                  token='bad')), url_for('bs.index'))
Пример #22
0
 def test_signup_get(self):
     with app.app_context():
         resp = self.app.get(url_for('bs.signup'))
     self.assertSubstr(forms.CPW_LABEL, resp)
Пример #23
0
 def test_rm_mail_invalid_mail_id(self):
     self.login(email, password)
     with app.app_context(), self.assertRaises(ValueError):
         self.app.get(url_for('bs.rmmail', character_id=123, mail_id='bad'))
Пример #24
0
 def test_signup_existing(self):
     add_user2()
     with app.app_context():
         resp = self.signup(email2, password2, password2)
         self.assertSubstr(SIGNUP_FAILED, resp)
Пример #25
0
 def test_change_pw_get(self):
     add_user2()
     self.login(email2, password2)
     with app.app_context():
         resp = self.app.get(url_for('bs.password'))
     self.assertSubstr(forms.CURRENT_LABEL, resp)
Пример #26
0
 def test_selfdestruct_get(self):
     add_user2()
     self.login(email2, password2)
     with app.app_context():
         resp = self.app.get(url_for('bs.selfdestruct'))
     self.assertTrue(b'really want to delete your account' in resp.data)
Пример #27
0
 def selfdestruct(self, eml, pw):
     data = dict(email=eml, password=pw)
     with app.app_context():
         return self.app.post(url_for('bs.selfdestruct'),
                              data=data,
                              follow_redirects=True)
Пример #28
0
 def test_activate_unknown_email(self):
     with app.app_context():
         self.assertRedirect(
             self.app.get(url_for('bs.activate', email='bad', token='x')),
             url_for('bs.index'))
Пример #29
0
 def test_index(self):
     with app.app_context():
         resp = self.app.get(url_for('bs.index'))
     self.assertEqual(resp.status_code, 200)
Пример #30
0
 def test_dashboard(self):
     add_user2()
     self.login(email2, password2)
     with app.app_context():
         resp = self.app.get(url_for('bs.dashboard'))
     self.assertAppVersion(resp)