This file is indexed.

/usr/lib/python2.7/dist-packages/ubuntu-sso-client/ubuntu_sso/utils/tests/test_ui.py is in python-ubuntu-sso-client.tests 13.10-0ubuntu11.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# -*- coding: utf-8 -*-
# Author: Manuel de la Pena <manuel@canonical.com>
#
# Copyright 2011-2012 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the
# OpenSSL library under certain conditions as described in each
# individual source file, and distribute linked combinations
# including the two.
# You must obey the GNU General Public License in all respects
# for all of the code used other than OpenSSL.  If you modify
# file(s) with this exception, you may extend this exception to your
# version of the file(s), but you are not obligated to do so.  If you
# do not wish to do so, delete this exception statement from your
# version.  If you delete this exception statement from all source
# files in the program, then also delete it here.
"""Test the ui functions."""

from unittest import TestCase

from ubuntu_sso.utils.ui import (get_password_strength,
                                 is_min_required_password,
                                 is_correct_email)


class GettextTestCase(TestCase):
    """Test that we don't override builtins with gettext."""

    def test_import(self):
        """Test whether importing ui module defines _ as a builtin."""
        # This module is already imported above, but just to make sure, since
        # top imports may change over time.
        import ubuntu_sso.utils.ui
        assert(ubuntu_sso.utils.ui)
        self.assertFalse('_' in __builtins__)


class GetPasswordStrengTestCase(TestCase):
    """Test the function that returns the strength of a password."""

    def test_too_small_password(self):
        """Test the points given to a very small password."""
        password = 'abc'
        self.assertEqual(1, get_password_strength(password))

    def test_small_password(self):
        """Test the points given to a small passwod 4 or more chars."""
        password = 'testtwe'
        self.assertEqual(0, get_password_strength(password))

    def test_eight_chars_password(self):
        """Test the points given to a normal 8 chars password."""
        password = 'abcdabcd'
        self.assertEqual(1, get_password_strength(password))

    def test_eight_chars_and_num(self):
        """Test the points given to a 8 chars password with a num."""
        password = 'abcdabc8'
        self.assertEqual(2, get_password_strength(password))

    def test_eight_chars_low_and_cap(self):
        """Test the points given to a 8 chars password with a capital."""
        password = 'abcdabcD'
        self.assertEqual(2, get_password_strength(password))

    def test_eight_chars_low_canp_num(self):
        """Test the points given to a 8 chars password with capitals & num."""
        password = 'abcdab7D'
        self.assertEqual(3, get_password_strength(password))

    def test_eiqgh_chars_and_special(self):
        """Test the points given to a 8 chars password with special chars."""
        password = 'abcdabc*'
        self.assertEqual(2, get_password_strength(password))

    def test_long_password(self):
        """Test the points goven to a long password."""
        password = 'abcdabcdabcd'
        self.assertEqual(2, get_password_strength(password))

    def test_eleven_chars_and_num(self):
        """Test the points of a loong password with a num."""
        password = 'abcdabcdabcd99'
        self.assertEqual(3, get_password_strength(password))

    def test_eleven_chars_low_cap(self):
        """Test the points of a long password with low and cap."""
        password = 'abcdabcdabcdbABCD'
        self.assertEqual(3, get_password_strength(password))

    def test_eleven_num_low_cap(self):
        """Test the points of a long password with num and diff cap."""
        password = 'ABCDabcdacbd723'
        self.assertEqual(4, get_password_strength(password))

    def test_eleven_num_special(self):
        """Test the point of a long password with a number and special char."""
        password = 'abcdabcdabcd*9'
        self.assertEqual(4, get_password_strength(password))


class IsMinRequiredPasswordTestCase(TestCase):
    """Test the fnction that returns if the password is the min required."""

    def test_no_enough_chars(self):
        """Test a password that does not have enough chars."""
        password = 'Test8'
        self.assertFalse(is_min_required_password(password))

    def test_no_uppercase(self):
        """Test a password that does not have an uppercase."""
        password = 'longenoughtobeapassword8'
        self.assertFalse(is_min_required_password(password))

    def test_no_number(self):
        """Test a password that does not have a number."""
        password = 'longenoughtobeapassworD'
        self.assertFalse(is_min_required_password(password))

    def test_correct_password(self):
        """Test a password that is correct."""
        password = 'TodasLasPaswordPasan88'
        self.assertTrue(is_min_required_password(password))


class IsCorrectEmailAddress(TestCase):
    """Test the is_correct_email funtion."""

    def test_is_correct_email_true(self):
        """Test when the email is correct."""
        email = 'manuel@canonical.com'
        self.assertTrue(is_correct_email(email))

    def test_is_correct_email_false(self):
        """Test when the email is not correct."""
        email = 'manuelcanonical.com'
        self.assertFalse(is_correct_email(email))