This file is indexed.

/usr/lib/python2.7/dist-packages/ironicclient/tests/functional/test_chassis_create.py is in python-ironicclient 2.2.0-0ubuntu1.

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
# Copyright (c) 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import six
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions

from ironicclient.tests.functional import base


class NegativeChassisCreateTestsIronicClient(base.FunctionalTestBase):
    """Negative tests for testing chassis-create command.

    Negative tests for the Ironic CLI commands which check actions with
    chassis-create command like create chassis without arguments or with
    incorrect arguments and check that correct error message raised.
    """

    error_msg = r'ironic chassis-create: error:'
    expected_msg = r'expected one argument'

    def test_description_no_value(self):
        """Test steps:

        1) create chassis using -d argument without the value
        2) create chassis using --description argument without the value
        3) check that command using -d argument triggers an exception
        4) check that command with --description arg triggers an exception
        """
        ex_text = (r'{0} argument -d/--description: {1}'
                   .format(self.error_msg, self.expected_msg))
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis, '-d')
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis, '--description')

    def test_metadata_extra_no_value(self):
        """Test steps:

        1) create chassis using -e argument without the value
        2) create chassis using --extra argument without the value
        3) check that command using -e argument triggers an exception
        4) check that command with --extra argument triggers an exception
        """
        ex_text = (r'{0} argument -e/--extra: {1}'
                   .format(self.error_msg, self.expected_msg))
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis, '-e')
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis, '--extra')

    def test_specific_uuid_no_value(self):
        """Test steps:

        1) create chassis using -u argument without the value
        2) create chassis using --uuid argument without the value
        3) check that command using -u argument triggers an exception
        4) check that command with --uuid argument triggers an exception
        """
        ex_text = (r'{0} argument -u/--uuid: {1}'
                   .format(self.error_msg, self.expected_msg))
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis, '-u')
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis, '--uuid')

    def test_invalid_description(self):
        """Test steps:

        1) create chassis with invalid description using -d argument
        2) create chassis with invalid description using --description arg
        3) check that command using -d argument triggers an exception
        4) check that command using --uuid argument triggers an exception
        """
        description = '--'
        ex_text = (r'{0} argument -d/--description: {1}'
                   .format(self.error_msg, self.expected_msg))
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis,
                              params='-d {0}'.format(description))
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis,
                              params='--description {0}'.format(description))

    def test_invalid_metadata_extra(self):
        """Test steps:

        1) create chassis with invalid metadata using -e argument
        2) create chassis with invalid metadata using --extra argument
        3) check that command using -e argument triggers an exception
        4) check that command using --extra argument triggers an exception
        """
        extra = "HelloWorld"
        ex_text = (r'{0} Attributes must be a list of PATH=VALUE'
                   .format(self.error_msg))
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis,
                              params='-e {0}'.format(extra))
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis,
                              params='--extra {0}'.format(extra))

    def test_invalid_specific_uuid(self):
        """Test steps:

        1) create chassis with invalid specific uuid using -u argument
        2) create chassis with invalid specific uuid using --uuid argument
        3) check that command using -u argument triggers an exception
        4) check that command using --uuid argument triggers an exception
        """
        invalid_uuid = data_utils.rand_uuid()[:-1]
        ex_text = r'Expected a UUID but received {0}'.format(invalid_uuid)
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis,
                              params='-u {0}'.format(invalid_uuid))
        six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
                              self.create_chassis,
                              params='--uuid {0}'.format(invalid_uuid))