| 1 |
# Copyright 2015 gRPC authors. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
"""Constants and functions for data used in testing.""" |
| 15 |
|
| 16 |
import os |
| 17 |
import pkgutil |
| 18 |
|
| 19 |
_ROOT_CERTIFICATES_RESOURCE_PATH = 'credentials/ca.pem' |
| 20 |
_PRIVATE_KEY_RESOURCE_PATH = 'credentials/server1.key' |
| 21 |
_CERTIFICATE_CHAIN_RESOURCE_PATH = 'credentials/server1.pem' |
| 22 |
|
| 23 |
|
| 24 |
def test_root_certificates(): |
| 25 |
return pkgutil.get_data(__name__, _ROOT_CERTIFICATES_RESOURCE_PATH) |
| 26 |
|
| 27 |
|
| 28 |
def private_key(): |
| 29 |
return pkgutil.get_data(__name__, _PRIVATE_KEY_RESOURCE_PATH) |
| 30 |
|
| 31 |
|
| 32 |
def certificate_chain(): |
| 33 |
return pkgutil.get_data(__name__, _CERTIFICATE_CHAIN_RESOURCE_PATH) |
| 34 |
|
| 35 |
|
| 36 |
def cert_hier_1_root_ca_cert(): |
| 37 |
return pkgutil.get_data( |
| 38 |
__name__, 'credentials/certificate_hierarchy_1/certs/ca.cert.pem') |
| 39 |
|
| 40 |
|
| 41 |
def cert_hier_1_intermediate_ca_cert(): |
| 42 |
return pkgutil.get_data( |
| 43 |
__name__, |
| 44 |
'credentials/certificate_hierarchy_1/intermediate/certs/intermediate.cert.pem' |
| 45 |
) |
| 46 |
|
| 47 |
|
| 48 |
def cert_hier_1_client_1_key(): |
| 49 |
return pkgutil.get_data( |
| 50 |
__name__, |
| 51 |
'credentials/certificate_hierarchy_1/intermediate/private/client.key.pem' |
| 52 |
) |
| 53 |
|
| 54 |
|
| 55 |
def cert_hier_1_client_1_cert(): |
| 56 |
return pkgutil.get_data( |
| 57 |
__name__, |
| 58 |
'credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem' |
| 59 |
) |
| 60 |
|
| 61 |
|
| 62 |
def cert_hier_1_server_1_key(): |
| 63 |
return pkgutil.get_data( |
| 64 |
__name__, |
| 65 |
'credentials/certificate_hierarchy_1/intermediate/private/localhost-1.key.pem' |
| 66 |
) |
| 67 |
|
| 68 |
|
| 69 |
def cert_hier_1_server_1_cert(): |
| 70 |
return pkgutil.get_data( |
| 71 |
__name__, |
| 72 |
'credentials/certificate_hierarchy_1/intermediate/certs/localhost-1.cert.pem' |
| 73 |
) |
| 74 |
|
| 75 |
|
| 76 |
def cert_hier_2_root_ca_cert(): |
| 77 |
return pkgutil.get_data( |
| 78 |
__name__, 'credentials/certificate_hierarchy_2/certs/ca.cert.pem') |
| 79 |
|
| 80 |
|
| 81 |
def cert_hier_2_intermediate_ca_cert(): |
| 82 |
return pkgutil.get_data( |
| 83 |
__name__, |
| 84 |
'credentials/certificate_hierarchy_2/intermediate/certs/intermediate.cert.pem' |
| 85 |
) |
| 86 |
|
| 87 |
|
| 88 |
def cert_hier_2_client_1_key(): |
| 89 |
return pkgutil.get_data( |
| 90 |
__name__, |
| 91 |
'credentials/certificate_hierarchy_2/intermediate/private/client.key.pem' |
| 92 |
) |
| 93 |
|
| 94 |
|
| 95 |
def cert_hier_2_client_1_cert(): |
| 96 |
return pkgutil.get_data( |
| 97 |
__name__, |
| 98 |
'credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem' |
| 99 |
) |
| 100 |
|
| 101 |
|
| 102 |
def cert_hier_2_server_1_key(): |
| 103 |
return pkgutil.get_data( |
| 104 |
__name__, |
| 105 |
'credentials/certificate_hierarchy_2/intermediate/private/localhost-1.key.pem' |
| 106 |
) |
| 107 |
|
| 108 |
|
| 109 |
def cert_hier_2_server_1_cert(): |
| 110 |
return pkgutil.get_data( |
| 111 |
__name__, |
| 112 |
'credentials/certificate_hierarchy_2/intermediate/certs/localhost-1.cert.pem' |
| 113 |
) |