Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix symbol error and Fix SSLError when connect es. (#831)
Browse files Browse the repository at this point in the history
* Fix symbol error

Replace "—" with "--".

* Fix SSLError when connect es.

[why]
Execute "odfesql https://localhost:9200 -u admin -w admin",
Then raise "SSLError('N/A', '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)', SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)')))"

* Add "connection_class" parameter to "assert_called_with".

[why]
Because I modify "sql-cli/src/odfe_sql_cli/esconnection.py",
and add "connection_class" parameter when get es client.
to  fix SSLError when connect es.

But the test raise " AssertionError: expected call not found."

[how]
Add "connection_class" parameter to "assert_called_with".
  • Loading branch information
7-Leaf authored and penghuo committed Dec 15, 2020
1 parent 910704a commit f2d1fce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sql-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ To install the SQL CLI:
1. To launch the CLI, run:
```
odfesql https://localhost:9200 --username admin password admin
odfesql https://localhost:9200 --username admin --password admin
```
By default, the `odfesql` command connects to [http://localhost:9200](http://localhost:9200/).
Expand Down Expand Up @@ -90,7 +90,7 @@ For a list of all available configurations, see [clirc](https://github.com/opend
2. Index the sample data.
```
curl -H "Content-Type: application/x-ndjson" -POST https://localhost:9200/data/_bulk -u admin:admin --insecure data-binary "@accounts.json"
curl -H "Content-Type: application/x-ndjson" -POST https://localhost:9200/data/_bulk -u admin:admin --insecure --data-binary "@accounts.json"
```
Expand Down
3 changes: 2 additions & 1 deletion sql-cli/src/odfe_sql_cli/esconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def get_open_distro_client(self):
ssl_context.verify_mode = ssl.CERT_NONE

open_distro_client = Elasticsearch(
[self.endpoint], http_auth=self.http_auth, verify_certs=False, ssl_context=ssl_context
[self.endpoint], http_auth=self.http_auth, verify_certs=False, ssl_context=ssl_context,
connection_class=RequestsHttpConnection
)

return open_distro_client
Expand Down
3 changes: 2 additions & 1 deletion sql-cli/tests/test_esconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def test_get_od_client(self):
od_test_executor.get_open_distro_client()

mock_es.assert_called_with(
[OPEN_DISTRO_ENDPOINT], http_auth=AUTH, verify_certs=False, ssl_context=od_test_executor.ssl_context
[OPEN_DISTRO_ENDPOINT], http_auth=AUTH, verify_certs=False, ssl_context=od_test_executor.ssl_context,
connection_class=RequestsHttpConnection
)

def test_get_aes_client(self):
Expand Down

0 comments on commit f2d1fce

Please sign in to comment.