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
18import pkgutil
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 pkgutil.get_data(__name__, _ROOT_CERTIFICATES_RESOURCE_PATH)
27
28
29def private_key():
30    return pkgutil.get_data(__name__, _PRIVATE_KEY_RESOURCE_PATH)
31
32
33def certificate_chain():
34    return pkgutil.get_data(__name__, _CERTIFICATE_CHAIN_RESOURCE_PATH)
35
36
37def parse_bool(value):
38    if value == 'true':
39        return True
40    if value == 'false':
41        return False
42    raise argparse.ArgumentTypeError('Only true/false allowed')
43