/usr/lib/python2.7/dist-packages/tempest_lib/tests/fake_identity.py is in python-tempest-lib 0.14.0-3.
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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | # Copyright 2014 IBM Corp.
# All Rights Reserved.
#
# 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 json
import httplib2
FAKE_AUTH_URL = 'http://fake_uri.com/auth'
TOKEN = "fake_token"
ALT_TOKEN = "alt_fake_token"
# Fake Identity v2 constants
COMPUTE_ENDPOINTS_V2 = {
"endpoints": [
{
"adminURL": "http://fake_url/v2/first_endpoint/admin",
"region": "NoMatchRegion",
"internalURL": "http://fake_url/v2/first_endpoint/internal",
"publicURL": "http://fake_url/v2/first_endpoint/public"
},
{
"adminURL": "http://fake_url/v2/second_endpoint/admin",
"region": "FakeRegion",
"internalURL": "http://fake_url/v2/second_endpoint/internal",
"publicURL": "http://fake_url/v2/second_endpoint/public"
},
],
"type": "compute",
"name": "nova"
}
CATALOG_V2 = [COMPUTE_ENDPOINTS_V2, ]
ALT_IDENTITY_V2_RESPONSE = {
"access": {
"token": {
"expires": "2020-01-01T00:00:10Z",
"id": ALT_TOKEN,
"tenant": {
"id": "fake_alt_tenant_id"
},
},
"user": {
"id": "fake_alt_user_id",
},
"serviceCatalog": CATALOG_V2,
},
}
IDENTITY_V2_RESPONSE = {
"access": {
"token": {
"expires": "2020-01-01T00:00:10Z",
"id": TOKEN,
"tenant": {
"id": "fake_tenant_id"
},
},
"user": {
"id": "fake_user_id",
},
"serviceCatalog": CATALOG_V2,
},
}
# Fake Identity V3 constants
COMPUTE_ENDPOINTS_V3 = {
"endpoints": [
{
"id": "first_compute_fake_service",
"interface": "public",
"region": "NoMatchRegion",
"url": "http://fake_url/v3/first_endpoint/api"
},
{
"id": "second_fake_service",
"interface": "public",
"region": "FakeRegion",
"url": "http://fake_url/v3/second_endpoint/api"
},
{
"id": "third_fake_service",
"interface": "admin",
"region": "MiddleEarthRegion",
"url": "http://fake_url/v3/third_endpoint/api"
}
],
"type": "compute",
"id": "fake_compute_endpoint"
}
CATALOG_V3 = [COMPUTE_ENDPOINTS_V3, ]
IDENTITY_V3_RESPONSE = {
"token": {
"methods": [
"token",
"password"
],
"expires_at": "2020-01-01T00:00:10.000123Z",
"project": {
"domain": {
"id": "fake_domain_id",
"name": "fake"
},
"id": "project_id",
"name": "project_name"
},
"user": {
"domain": {
"id": "fake_domain_id",
"name": "domain_name"
},
"id": "fake_user_id",
"name": "username"
},
"issued_at": "2013-05-29T16:55:21.468960Z",
"catalog": CATALOG_V3
}
}
ALT_IDENTITY_V3 = IDENTITY_V3_RESPONSE
def _fake_v3_response(self, uri, method="GET", body=None, headers=None,
redirections=5, connection_type=None):
fake_headers = {
"status": "201",
"x-subject-token": TOKEN
}
return (httplib2.Response(fake_headers),
json.dumps(IDENTITY_V3_RESPONSE))
def _fake_v2_response(self, uri, method="GET", body=None, headers=None,
redirections=5, connection_type=None):
return (httplib2.Response({"status": "200"}),
json.dumps(IDENTITY_V2_RESPONSE))
def _fake_auth_failure_response():
# the response body isn't really used in this case, but lets send it anyway
# to have a safe check in some future change on the rest client.
body = {
"unauthorized": {
"message": "Unauthorized",
"code": "401"
}
}
return httplib2.Response({"status": "401"}), json.dumps(body)
|