1 # ============LICENSE_START=======================================================
3 # ================================================================================
4 # Copyright (c) 2021 Nokia. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=========================================================
21 SAMPLE_SANS_INPUT = "example.org,test.onap.org,onap@onap.org,127.0.0.1,2001:0db8:85a3:0000:0000:8a2e:0370:7334,onap://cluster.local/"
24 def test_parse_dns_name():
25 from k8sclient.sans_parser import SansParser
26 result = SansParser().parse_sans(SAMPLE_SANS_INPUT)
27 dnss_array = result["dnss"]
28 assert len(dnss_array) == 2
29 assert assert_item_in_list("example.org", dnss_array)
33 from k8sclient.sans_parser import SansParser
34 result = SansParser().parse_sans(SAMPLE_SANS_INPUT)
35 ips_array = result["ips"]
36 assert len(ips_array) == 2
37 assert assert_item_in_list("127.0.0.1", ips_array)
38 assert assert_item_in_list("2001:0db8:85a3:0000:0000:8a2e:0370:7334", ips_array)
41 def test_parse_emails():
42 from k8sclient.sans_parser import SansParser
43 result = SansParser().parse_sans(SAMPLE_SANS_INPUT)
44 emails_array = result["emails"]
45 assert len(emails_array) == 1
46 assert assert_item_in_list("onap@onap.org", emails_array)
50 from k8sclient.sans_parser import SansParser
51 result = SansParser().parse_sans(SAMPLE_SANS_INPUT)
52 uris_array = result["uris"]
53 assert len(uris_array) == 1
54 assert assert_item_in_list("onap://cluster.local/", uris_array)
57 def assert_item_in_list(item, list):