diff options
author | 2021-02-24 13:14:44 +0100 | |
---|---|---|
committer | 2021-02-26 14:03:55 +0100 | |
commit | 721b765248cd1661a06470e190b8467fe777d3dd (patch) | |
tree | 8dce07401ba8ca0761c29191c69e0133660320d8 /k8s/tests/test_sans_parser.py | |
parent | 56f25871c2ee7f33799a3985ec5e1215b196f3dd (diff) |
Add certificate custom resource creation when CertManager CMPv2 integration is enabled
Issue-ID: DCAEGEN2-2440
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: Icc2006af0520d592bfdf46d4f9fe419d7b5bc81e
Diffstat (limited to 'k8s/tests/test_sans_parser.py')
-rw-r--r-- | k8s/tests/test_sans_parser.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/k8s/tests/test_sans_parser.py b/k8s/tests/test_sans_parser.py new file mode 100644 index 0000000..f860fd7 --- /dev/null +++ b/k8s/tests/test_sans_parser.py @@ -0,0 +1,61 @@ +# ============LICENSE_START======================================================= +# org.onap.dcae +# ================================================================================ +# Copyright (c) 2021 Nokia. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +# import pytest + +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/" + + +def test_parse_dns_name(): + from k8sclient.sans_parser import SansParser + result = SansParser().parse_sans(SAMPLE_SANS_INPUT) + dnss_array = result["dnss"] + assert len(dnss_array) == 2 + assert assert_item_in_list("example.org", dnss_array) + + +def test_parse_ips(): + from k8sclient.sans_parser import SansParser + result = SansParser().parse_sans(SAMPLE_SANS_INPUT) + ips_array = result["ips"] + assert len(ips_array) == 2 + assert assert_item_in_list("127.0.0.1", ips_array) + assert assert_item_in_list("2001:0db8:85a3:0000:0000:8a2e:0370:7334", ips_array) + + +def test_parse_emails(): + from k8sclient.sans_parser import SansParser + result = SansParser().parse_sans(SAMPLE_SANS_INPUT) + emails_array = result["emails"] + assert len(emails_array) == 1 + assert assert_item_in_list("onap@onap.org", emails_array) + + +def test_parse_uri(): + from k8sclient.sans_parser import SansParser + result = SansParser().parse_sans(SAMPLE_SANS_INPUT) + uris_array = result["uris"] + assert len(uris_array) == 1 + assert assert_item_in_list("onap://cluster.local/", uris_array) + + +def assert_item_in_list(item, list): + if item in list: + return True + else: + return False |