This file is indexed.

/usr/lib/python3/dist-packages/keystoneclient/tests/functional/v3/test_ec2.py is in python3-keystoneclient 1:3.15.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
# 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.

from keystoneauth1.exceptions import http

from keystoneclient.tests.functional import base
from keystoneclient.tests.functional.v3 import client_fixtures as fixtures


class EC2TestCase(base.V3ClientTestCase):

    def check_ec2(self, ec2, ec2_ref=None):
        self.assertIn('self', ec2.links)
        self.assertIn('/users/%s/credentials/OS-EC2/%s'
                      % (ec2.user_id, ec2.access), ec2.links['self'])

        if ec2_ref:
            self.assertEqual(ec2_ref['user_id'], ec2.user_id)
            self.assertEqual(ec2_ref['project_id'], ec2.tenant_id)

        else:
            self.assertIsNotNone(ec2.user_id)
            self.assertIsNotNone(ec2.tenant_id)

    def test_create_ec2(self):
        user = fixtures.User(self.client, self.project_domain_id)
        self.useFixture(user)
        project = fixtures.Project(self.client, self.project_domain_id)
        self.useFixture(project)

        ec2_ref = {'user_id': user.id,
                   'project_id': project.id}
        ec2 = self.client.ec2.create(**ec2_ref)

        self.addCleanup(self.client.ec2.delete, user.id, ec2.access)
        self.check_ec2(ec2, ec2_ref)

    def test_get_ec2(self):
        user = fixtures.User(self.client, self.project_domain_id)
        self.useFixture(user)
        project = fixtures.Project(self.client, self.project_domain_id)
        self.useFixture(project)

        ec2 = fixtures.EC2(self.client, user_id=user.id, project_id=project.id)
        self.useFixture(ec2)

        ec2_ret = self.client.ec2.get(user.id, ec2.access)
        self.check_ec2(ec2_ret, ec2.ref)

    def test_list_ec2(self):
        user_one = fixtures.User(self.client, self.project_domain_id)
        self.useFixture(user_one)
        ec2_one = fixtures.EC2(self.client, user_id=user_one.id,
                               project_id=self.project_domain_id)
        self.useFixture(ec2_one)

        user_two = fixtures.User(self.client, self.project_domain_id)
        self.useFixture(user_two)
        ec2_two = fixtures.EC2(self.client, user_id=user_two.id,
                               project_id=self.project_domain_id)
        self.useFixture(ec2_two)

        ec2_list = self.client.ec2.list(user_one.id)

        # All ec2 are valid
        for ec2 in ec2_list:
            self.check_ec2(ec2)

        self.assertIn(ec2_one.entity, ec2_list)
        self.assertNotIn(ec2_two.entity, ec2_list)

    def test_delete_ec2(self):
        user = fixtures.User(self.client, self.project_domain_id)
        self.useFixture(user)
        project = fixtures.Project(self.client, self.project_domain_id)
        self.useFixture(project)

        ec2 = self.client.ec2.create(user.id, project.id)

        self.client.ec2.delete(user.id, ec2.access)
        self.assertRaises(http.NotFound,
                          self.client.ec2.get,
                          user.id, ec2.access)