Example #1
0
    def test_validate_no_whitespace(self):
        data = "no_white_space"
        result = attributes._validate_no_whitespace(data)
        self.assertEqual(result, data)

        self.assertRaises(q_exc.InvalidInput, attributes._validate_no_whitespace, "i have whitespace")

        self.assertRaises(q_exc.InvalidInput, attributes._validate_no_whitespace, "i\thave\twhitespace")
Example #2
0
    def test_validate_no_whitespace(self):
        data = 'no_white_space'
        result = attributes._validate_no_whitespace(data)
        self.assertEqual(result, data)

        self.assertRaises(n_exc.InvalidInput,
                          attributes._validate_no_whitespace,
                          'i have whitespace')

        self.assertRaises(n_exc.InvalidInput,
                          attributes._validate_no_whitespace,
                          'i\thave\twhitespace')
Example #3
0
    def test_validate_no_whitespace(self):
        data = 'no_white_space'
        result = attributes._validate_no_whitespace(data)
        self.assertEqual(result, data)

        self.assertRaises(n_exc.InvalidInput,
                          attributes._validate_no_whitespace,
                          'i have whitespace')

        self.assertRaises(n_exc.InvalidInput,
                          attributes._validate_no_whitespace,
                          'i\thave\twhitespace')
Example #4
0
    def test_validate_no_whitespace(self):
        data = "no_white_space"
        result = attributes._validate_no_whitespace(data)
        self.assertEqual(data, result)

        self.assertRaises(n_exc.InvalidInput, attributes._validate_no_whitespace, "i have whitespace")

        self.assertRaises(n_exc.InvalidInput, attributes._validate_no_whitespace, "i\thave\twhitespace")

        for ws in string.whitespace:
            self.assertRaises(n_exc.InvalidInput, attributes._validate_no_whitespace, "%swhitespace-at-head" % ws)
            self.assertRaises(n_exc.InvalidInput, attributes._validate_no_whitespace, "whitespace-at-tail%s" % ws)
Example #5
0
def _validate_gre_key(data, valid_values=None):
    # A gre key can always be transfered to an ipv4 address
    if not data:
        return
    try:
        netaddr.IPAddress(attr._validate_no_whitespace(data))
    except Exception:
        try:
            if int(data) == 2**32:  # since IPAddress doesn't recognize 2**32.
                return
            else:
                raise ConnectionKeyInvalid(key=data)
        except ValueError:
            raise ConnectionKeyInvalid(key=data)
Example #6
0
def _validate_gre_key(data, valid_values=None):
    # A gre key can always be transfered to an ipv4 address
    if not data:
        return
    try:
        netaddr.IPAddress(attr._validate_no_whitespace(data))
    except Exception:
        try:
            if int(data) == 2**32:  # since IPAddress doesn't recognize 2**32.
                return
            else:
                raise ConnectionKeyInvalid(key=data)
        except ValueError:
            raise ConnectionKeyInvalid(key=data)
Example #7
0
    def test_validate_no_whitespace(self):
        data = 'no_white_space'
        result = attributes._validate_no_whitespace(data)
        self.assertEqual(data, result)

        self.assertRaises(n_exc.InvalidInput,
                          attributes._validate_no_whitespace,
                          'i have whitespace')

        self.assertRaises(n_exc.InvalidInput,
                          attributes._validate_no_whitespace,
                          'i\thave\twhitespace')

        for ws in string.whitespace:
            self.assertRaises(n_exc.InvalidInput,
                              attributes._validate_no_whitespace,
                              '%swhitespace-at-head' % ws)
            self.assertRaises(n_exc.InvalidInput,
                              attributes._validate_no_whitespace,
                              'whitespace-at-tail%s' % ws)
    def test_validate_no_whitespace(self):
        data = 'no_white_space'
        result = attributes._validate_no_whitespace(data)
        self.assertEqual(data, result)

        self.assertRaises(n_exc.InvalidInput,
                          attributes._validate_no_whitespace,
                          'i have whitespace')

        self.assertRaises(n_exc.InvalidInput,
                          attributes._validate_no_whitespace,
                          'i\thave\twhitespace')

        for ws in string.whitespace:
            self.assertRaises(n_exc.InvalidInput,
                              attributes._validate_no_whitespace,
                              '%swhitespace-at-head' % ws)
            self.assertRaises(n_exc.InvalidInput,
                              attributes._validate_no_whitespace,
                              'whitespace-at-tail%s' % ws)