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 interoperability testing.""" 15 16import argparse 17import os 18 19import pkg_resources 20 21_ROOT_CERTIFICATES_RESOURCE_PATH = 'credentials/ca.pem' 22_PRIVATE_KEY_RESOURCE_PATH = 'credentials/server1.key' 23_CERTIFICATE_CHAIN_RESOURCE_PATH = 'credentials/server1.pem' 24 25 26def test_root_certificates(): 27 return pkg_resources.resource_string(__name__, 28 _ROOT_CERTIFICATES_RESOURCE_PATH) 29 30 31def private_key(): 32 return pkg_resources.resource_string(__name__, _PRIVATE_KEY_RESOURCE_PATH) 33 34 35def certificate_chain(): 36 return pkg_resources.resource_string(__name__, 37 _CERTIFICATE_CHAIN_RESOURCE_PATH) 38 39 40def parse_bool(value): 41 if value == 'true': 42 return True 43 if value == 'false': 44 return False 45 raise argparse.ArgumentTypeError('Only true/false allowed') 46