Skip to content

Commit 1c36f75

Browse files
authored
Merge branch 'master' into 1.1.3
2 parents 6b4e5c6 + 959c0d7 commit 1c36f75

File tree

98 files changed

+3072
-888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+3072
-888
lines changed

.github/workflows/ci.yaml

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,93 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', 'pypy-3.9']
11+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.10']
12+
13+
env:
14+
REALM: test
15+
USER: oauth_user
16+
PASSWORD: password
17+
CLIENT_ID: vertica
18+
CLIENT_SECRET: P9f8350QQIUhFfK1GF5sMhq4Dm3P6Sbs
1219

1320
steps:
1421
- name: Check out repository
15-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
1623
- name: Set up Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v5
1825
with:
1926
python-version: ${{ matrix.python-version }}
20-
- name: Set up a Vertica server
21-
env:
22-
VERTICA_CE_URL: "https://vertica-community-edition-for-testing.s3.amazonaws.com/XCz9cp7m/vertica-12.0.0-0.x86_64.RHEL6.rpm"
27+
- name: Set up a Keycloak docker container
28+
timeout-minutes: 5
29+
run: |
30+
docker network create -d bridge my-network
31+
docker run -d -p 8080:8080 \
32+
--name keycloak --network my-network \
33+
-e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin \
34+
quay.io/keycloak/keycloak:23.0.4 start-dev
35+
docker container ls
36+
37+
- name: Set up a Vertica server docker container
38+
timeout-minutes: 15
39+
run: |
40+
docker run -d -p 5433:5433 -p 5444:5444 \
41+
--name vertica_docker --network my-network \
42+
opentext/vertica-ce:24.4.0-0
43+
echo "Vertica startup ..."
44+
until docker exec vertica_docker test -f /data/vertica/VMart/agent_start.out; do \
45+
echo "..."; \
46+
sleep 3; \
47+
done;
48+
echo "Vertica is up"
49+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "\l"
50+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "select version()"
51+
52+
- name: Configure Keycloak
2353
run: |
24-
git clone https://github.com/jbfavre/docker-vertica.git
25-
curl $VERTICA_CE_URL --create-dirs -o docker-vertica/packages/vertica-ce.latest.rpm
26-
docker build -f docker-vertica/Dockerfile.centos.7_9.x --build-arg VERTICA_PACKAGE=vertica-ce.latest.rpm -t jbfavre/vertica docker-vertica
27-
docker images
28-
docker run -d -p 5433:5433 jbfavre/vertica
29-
sleep 60
54+
echo "Wait for keycloak ready ..."
55+
bash -c 'while true; do curl -s localhost:8080 &>/dev/null; ret=$?; [[ $ret -eq 0 ]] && break; echo "..."; sleep 3; done'
56+
57+
docker exec -i keycloak /bin/bash <<EOF
58+
/opt/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080 --realm master --user admin --password admin
59+
/opt/keycloak/bin/kcadm.sh create realms -s realm=${REALM} -s enabled=true
60+
/opt/keycloak/bin/kcadm.sh update realms/${REALM} -s accessTokenLifespan=3600
61+
/opt/keycloak/bin/kcadm.sh get realms/${REALM}
62+
/opt/keycloak/bin/kcadm.sh create users -r ${REALM} -s username=${USER} -s enabled=true
63+
/opt/keycloak/bin/kcadm.sh set-password -r ${REALM} --username ${USER} --new-password ${PASSWORD}
64+
/opt/keycloak/bin/kcadm.sh get users -r ${REALM}
65+
/opt/keycloak/bin/kcadm.sh create clients -r ${REALM} -s clientId=${CLIENT_ID} -s enabled=true \
66+
-s 'redirectUris=["/*"]' -s 'webOrigins=["/*"]' -s secret=${CLIENT_SECRET} -s directAccessGrantsEnabled=true -o
67+
EOF
68+
69+
# Retrieving an Access Token
70+
curl --location --request POST http://`hostname`:8080/realms/${REALM}/protocol/openid-connect/token \
71+
--header 'Content-Type: application/x-www-form-urlencoded' \
72+
--data-urlencode "username=${USER}" \
73+
--data-urlencode "password=${PASSWORD}" \
74+
--data-urlencode "client_id=${CLIENT_ID}" \
75+
--data-urlencode "client_secret=${CLIENT_SECRET}" \
76+
--data-urlencode 'grant_type=password' -o oauth.json
77+
cat oauth.json | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj["access_token"])' > access_token.txt
78+
79+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "CREATE AUTHENTICATION v_oauth METHOD 'oauth' HOST '0.0.0.0/0';"
80+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "ALTER AUTHENTICATION v_oauth SET client_id = '${CLIENT_ID}';"
81+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "ALTER AUTHENTICATION v_oauth SET client_secret = '${CLIENT_SECRET}';"
82+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "ALTER AUTHENTICATION v_oauth SET discovery_url = 'http://`hostname`:8080/realms/${REALM}/.well-known/openid-configuration';"
83+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "ALTER AUTHENTICATION v_oauth SET introspect_url = 'http://`hostname`:8080/realms/${REALM}/protocol/openid-connect/token/introspect';"
84+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "SELECT * FROM client_auth WHERE auth_name='v_oauth';"
85+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "CREATE USER ${USER};"
86+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "GRANT AUTHENTICATION v_oauth TO ${USER};"
87+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "GRANT ALL ON SCHEMA PUBLIC TO ${USER};"
88+
# A dbadmin-specific authentication record (connect remotely) is needed after setting up an OAuth user
89+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "CREATE AUTHENTICATION v_dbadmin_hash METHOD 'hash' HOST '0.0.0.0/0';"
90+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "ALTER AUTHENTICATION v_dbadmin_hash PRIORITY 10000;"
91+
docker exec -u dbadmin vertica_docker /opt/vertica/bin/vsql -c "GRANT AUTHENTICATION v_dbadmin_hash TO dbadmin;"
92+
3093
- name: Install dependencies
3194
run: pip install tox
3295
- name: Run tests
3396
run: |
3497
export VP_TEST_USER=dbadmin
98+
export VP_TEST_OAUTH_ACCESS_TOKEN=`cat access_token.txt`
99+
export VP_TEST_OAUTH_USER=${USER}
35100
tox -e py

CONTRIBUTING.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This document will guide you through the contribution process. There are a numbe
1010

1111
If you find a bug, submit an [issue](https://github.com/vertica/vertica-python/issues) with a complete and reproducible bug report. If the issue can't be reproduced, it will be closed. If you opened an issue, but figured out the answer later on your own, comment on the issue to let people know, then close the issue.
1212

13-
For issues (e.g. security related issues) that are **not suitable** to be reported publicly on the GitHub issue system, report your issues to [Vertica open source team](mailto:vertica-opensrc@microfocus.com) directly or file a case with Vertica support if you have a support account.
13+
For issues (e.g. security related issues) that are **not suitable** to be reported publicly on the GitHub issue system, report your issues to [Vertica open source team](mailto:vertica-opensrc@opentext.com) directly or file a case with Vertica support if you have a support account.
1414

1515
# Feature Requests
1616

@@ -73,8 +73,7 @@ If you do Kerberos development, you need to install additional [dependencies](RE
7373
We appreciate any and all [contributions to the test suite](#tests)! These tests use a Python module: [pytest](https://docs.pytest.org/en/latest/). You might want to check out the pytest documentation for more details.
7474

7575
There are two types of tests: unit tests and integration tests. Unit tests do simple unit testing of individual classes and functions, which do not require database connection. Integration tests need to connect to a Vertica database to run stuffs, so you must have access to a Vertica database. We recommend using a non-production database, because some tests need the superuser permission to manipulate global settings and potentially break that database. Heres one way to go about it:
76-
- Download docker kitematic: https://kitematic.com/
77-
- Spin up a vertica container (e.g. sumitchawla/vertica)
76+
- Spin up a vertica docker container (e.g. [vertica/vertica-ce](https://hub.docker.com/r/vertica/vertica-ce))
7877

7978
Spin up your Vertica database for integration tests and then config test settings:
8079
* Here are default settings:
@@ -126,20 +125,20 @@ Examples of running tests:
126125
tox
127126

128127
# Run tests on specified python versions with `tox -e ENV,ENV`
129-
tox -e py27,py35
128+
tox -e py312,py313
130129

131130
# Run specific tests by filename (e.g.) `test_notice.py`
132131
tox -- vertica_python/tests/unit_tests/test_notice.py
133132

134-
# Run all unit tests on the python version 3.6:
135-
tox -e py36 -- -m unit_tests
133+
# Run all unit tests on the python version 3.9:
134+
tox -e py39 -- -m unit_tests
136135

137-
# Run all integration tests on the python version 3.4 with verbose result outputs:
138-
tox -e py34 -- -v -m integration_tests
136+
# Run all integration tests on the python version 3.10 with verbose result outputs:
137+
tox -e py310 -- -v -m integration_tests
139138

140139
# Run an individual test on specified python versions.
141-
# e.g.: Run the test `test_error_message` under `test_notice.py` on the python versions 2.7 and 3.5
142-
tox -e py27,py35 -- vertica_python/tests/unit_tests/test_notice.py::NoticeTestCase::test_error_message
140+
# e.g.: Run the test `test_error_message` under `test_notice.py` on the python versions 3.8 and 3.9
141+
tox -e py38,py39 -- vertica_python/tests/unit_tests/test_notice.py::NoticeTestCase::test_error_message
143142
```
144143

145144
The arguments after the `--` will be substituted everywhere where you specify `{posargs}` in your test *commands* of
@@ -163,7 +162,7 @@ At this point, you're ready to make your changes! Feel free to ask for help; eve
163162
Every file in this project must use the following Apache 2.0 header (with the appropriate year or years in the "[yyyy]" box; if a copyright statement from another party is already present in the code, you may add the statement on top of the existing copyright statement):
164163

165164
```
166-
Copyright (c) [yyyy] Micro Focus or one of its affiliates.
165+
Copyright (c) [yyyy] Open Text.
167166
168167
Licensed under the Apache License, Version 2.0 (the "License");
169168
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)