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 16import os 17 18import pkg_resources 19 20_ROOT_CERTIFICATES_RESOURCE_PATH = 'credentials/ca.pem' 21_PRIVATE_KEY_RESOURCE_PATH = 'credentials/server1.key' 22_CERTIFICATE_CHAIN_RESOURCE_PATH = 'credentials/server1.pem' 23 24 25def test_root_certificates(): 26 return pkg_resources.resource_string(__name__, 27 _ROOT_CERTIFICATES_RESOURCE_PATH) 28 29 30def private_key(): 31 return pkg_resources.resource_string(__name__, _PRIVATE_KEY_RESOURCE_PATH) 32 33 34def certificate_chain(): 35 return pkg_resources.resource_string(__name__, 36 _CERTIFICATE_CHAIN_RESOURCE_PATH) 37 38 39def cert_hier_1_root_ca_cert(): 40 return pkg_resources.resource_string( 41 __name__, 'credentials/certificate_hierarchy_1/certs/ca.cert.pem') 42 43 44def cert_hier_1_intermediate_ca_cert(): 45 return pkg_resources.resource_string( 46 __name__, 47 'credentials/certificate_hierarchy_1/intermediate/certs/intermediate.cert.pem' 48 ) 49 50 51def cert_hier_1_client_1_key(): 52 return pkg_resources.resource_string( 53 __name__, 54 'credentials/certificate_hierarchy_1/intermediate/private/client.key.pem' 55 ) 56 57 58def cert_hier_1_client_1_cert(): 59 return pkg_resources.resource_string( 60 __name__, 61 'credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem' 62 ) 63 64 65def cert_hier_1_server_1_key(): 66 return pkg_resources.resource_string( 67 __name__, 68 'credentials/certificate_hierarchy_1/intermediate/private/localhost-1.key.pem' 69 ) 70 71 72def cert_hier_1_server_1_cert(): 73 return pkg_resources.resource_string( 74 __name__, 75 'credentials/certificate_hierarchy_1/intermediate/certs/localhost-1.cert.pem' 76 ) 77 78 79def cert_hier_2_root_ca_cert(): 80 return pkg_resources.resource_string( 81 __name__, 'credentials/certificate_hierarchy_2/certs/ca.cert.pem') 82 83 84def cert_hier_2_intermediate_ca_cert(): 85 return pkg_resources.resource_string( 86 __name__, 87 'credentials/certificate_hierarchy_2/intermediate/certs/intermediate.cert.pem' 88 ) 89 90 91def cert_hier_2_client_1_key(): 92 return pkg_resources.resource_string( 93 __name__, 94 'credentials/certificate_hierarchy_2/intermediate/private/client.key.pem' 95 ) 96 97 98def cert_hier_2_client_1_cert(): 99 return pkg_resources.resource_string( 100 __name__, 101 'credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem' 102 ) 103 104 105def cert_hier_2_server_1_key(): 106 return pkg_resources.resource_string( 107 __name__, 108 'credentials/certificate_hierarchy_2/intermediate/private/localhost-1.key.pem' 109 ) 110 111 112def cert_hier_2_server_1_cert(): 113 return pkg_resources.resource_string( 114 __name__, 115 'credentials/certificate_hierarchy_2/intermediate/certs/localhost-1.cert.pem' 116 ) 117