Ejemplo n.º 1
0
 def test_correct_user_passed(self):
     user = User.get(self.username)
     self.assert_user_data_passed(
         user=user,
         login=self.username,
         name=self.user_dict['gecos'],
     )
Ejemplo n.º 2
0
 def setUp(self):
     super().setUp()
     account = self.fixtures_pg[Account][0].account
     # re-receive the account in order to get the relationship
     self.account = db.session.query(Account).filter_by(
         account=account).one()
     self.user = User(uid=self.account.account)
Ejemplo n.º 3
0
 def test_user_data_passed(self):
     user = User.authenticate(self.username, self.password)
     self.assert_user_data_passed(
         user=user,
         login=self.username,
         name=self.user_dict['gecos'],
     )
Ejemplo n.º 4
0
 def test_correct_user_passed(self):
     user = User.get(self.username)
     self.assert_user_data_passed(
         user=user,
         login=self.username,
         name=self.user_dict['gecos'],
     )
Ejemplo n.º 5
0
 def test_user_data_passed(self):
     user = User.authenticate(self.username, self.password)
     self.assert_user_data_passed(
         user=user,
         login=self.username,
         name=self.user_dict['gecos'],
     )
Ejemplo n.º 6
0
    def test_from_ip_without_account_anonymous(self):
        for ip in self.fixtures_pg[IP]:
            if ip.account:
                continue

            with self.subTest(ip=ip.ip):
                self.assertIsInstance(User.from_ip(ip.ip), AnonymousUserMixin)
Ejemplo n.º 7
0
    def test_from_ip_without_account_anonymous(self):
        for ip in self.fixtures_pg[IP]:
            if ip.account:
                continue

            with self.subTest(ip=ip.ip):
                self.assertIsInstance(User.from_ip(ip.ip), AnonymousUserMixin)
Ejemplo n.º 8
0
 def test_ips_passed(self):
     for account in self.fixtures[Account]:
         with self.subTest(account=account):
             user = User.get(account.account)
             expected_ips = self.session.query(Account).get(account.account).ips
             for ip in expected_ips:
                 with self.subTest(ip=ip):
                     self.assertIn(ip.ip, user.ips)
Ejemplo n.º 9
0
    def test_macs_passed(self):
        for mac in self.fixtures_pg.get(Mac, []):
            if mac.account is None:
                continue

            with self.subTest(mac=mac.mac):
                user = User.get(mac.account)
                self.assertIn(mac.mac.lower(), user.mac)
Ejemplo n.º 10
0
    def test_passive_user_status_correct(self):
        for account in self.accounts:
            if account.properties.active:
                continue

            with self.subTest(account=account):
                user = User.get(account.account)
                self.assertEqual(user.status, gettext("Passiv"))
Ejemplo n.º 11
0
 def test_ips_passed(self):
     for account in self.fixtures_pg[Account]:
         with self.subTest(account=account):
             user = User.get(account.account)
             expected_ips = self.session.query(Account).get(account.account).ips
             for ip in expected_ips:
                 with self.subTest(ip=ip):
                     self.assertIn(ip.ip, user.ips)
Ejemplo n.º 12
0
    def test_macs_passed(self):
        for mac in self.fixtures_pg.get(Mac, []):
            if mac.account is None:
                continue

            with self.subTest(mac=mac.mac):
                user = User.get(mac.account)
                self.assertIn(mac.mac.lower(), user.mac)
Ejemplo n.º 13
0
    def test_passive_user_status_correct(self):
        for account in self.accounts:
            if account.properties.active:
                continue

            with self.subTest(account=account):
                user = User.get(account.account)
                self.assertEqual(user.status, gettext("Passiv"))
Ejemplo n.º 14
0
 def setUp(self):
     super().setUp()
     self.user = User.get(self.account.account)
     self.history = self.user.traffic_history
Ejemplo n.º 15
0
 def test_auth_fail_with_old_password(self):
     with self.assertRaises(InvalidCredentials):
         User.authenticate(self.username, self.password)
Ejemplo n.º 16
0
 def test_from_ip_correct_user(self):
     for ip in self.fixtures_pg[IP]:
         if not ip.account:
             continue
         with self.subTest(ip=ip.ip):
             self.assertEqual(User.get(ip.account), User.from_ip(ip.ip))
Ejemplo n.º 17
0
 def test_from_ip_correct_user(self):
     for ip in self.fixtures_pg[IP]:
         if not ip.account:
             continue
         with self.subTest(ip=ip.ip):
             self.assertEqual(User.get(ip.account), User.from_ip(ip.ip))
Ejemplo n.º 18
0
 def test_user_is_active_or_not(self):
     for account in self.accounts:
         with self.subTest(account=account):
             user = User.get(account.account)
             self.assertEqual(user.has_connection, account.properties.active)
Ejemplo n.º 19
0
 def test_invalid_username_raises(self):
     with self.assertRaises(InvalidCredentials):
         User.authenticate(self.username + 'wrong', self.password)
Ejemplo n.º 20
0
 def test_user_is_connected_or_not(self):
     for account in self.accounts:
         with self.subTest(account=account):
             user = User.get(account.account)
             self.assertTrue(user.has_connection)
Ejemplo n.º 21
0
 def test_user_is_active_or_not(self):
     for account in self.accounts:
         with self.subTest(account=account):
             user = User.get(account.account)
             self.assertEqual(user.has_connection, account.properties.active)
Ejemplo n.º 22
0
 def test_auth_succeeds_with_new_password(self):
     try:
         User.authenticate(self.username, self.new_password)
     except InvalidCredentials:
         self.fail("Authentication failed with new password")
Ejemplo n.º 23
0
 def test_auth_fail_with_old_password(self):
     with self.assertRaises(InvalidCredentials):
         User.authenticate(self.username, self.password)
Ejemplo n.º 24
0
 def test_invalid_username_raises(self):
     with self.assertRaises(InvalidCredentials):
         User.authenticate(self.username + 'wrong', self.password)
Ejemplo n.º 25
0
 def test_user_get_uses_database(self):
     # A warning about a RuntimeError is thrown due to the
     # missing app context
     with disable_logs(logging.WARNING):
         self.assertIsInstance(User.get('test'), AnonymousUserMixin)
Ejemplo n.º 26
0
 def test_mail_correct(self):
     acc = self.fixtures_pg[Account][0]
     user = User.get(acc.account)
     expected_mail = "{}@wh12.tu-dresden.de".format(acc.account)
     self.assertEqual(user.mail, expected_mail)
Ejemplo n.º 27
0
 def setUp(self):
     super().setUp()
     self.user = User.get(self.account.account)
     self.history = self.user.traffic_history
Ejemplo n.º 28
0
 def test_user_is_connected_or_not(self):
     for account in self.accounts:
         with self.subTest(account=account):
             user = User.get(account.account)
             self.assertTrue(user.has_connection)
Ejemplo n.º 29
0
 def test_mail_correct(self):
     acc = self.fixtures_pg[Account][0]
     user = User.get(acc.account)
     expected_mail = "{}@wh12.tu-dresden.de".format(acc.account)
     self.assertEqual(user.mail, expected_mail)
Ejemplo n.º 30
0
 def test_auth_succeeds_with_new_password(self):
     try:
         User.authenticate(self.username, self.new_password)
     except InvalidCredentials:
         self.fail("Authentication failed with new password")