-
Notifications
You must be signed in to change notification settings - Fork 195
/
Copy pathtest_signer.py
34 lines (30 loc) · 1.15 KB
/
test_signer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
from unittest import TestCase
from opensearchpy.helpers.signer import derive_signature_url
class TestUrllib3Connection(TestCase):
def test_derive_signature_url(self):
assert (
derive_signature_url("http://localhost:10552/", singing_port=443)
== "http://localhost:443/"
)
assert (
derive_signature_url("http://localhost:10552/foo/bar", singing_port=443)
== "http://localhost:443/foo/bar"
)
assert (
derive_signature_url("http://localhost/", singing_port=443)
== "http://localhost:443/"
)
assert (
derive_signature_url("http://localhost/foo/bar", singing_port=443)
== "http://localhost:443/foo/bar"
)
def test_derive_signature_url_no_hostname(self):
self.assertRaises(RuntimeError, derive_signature_url, "http://", 23)