Skip to content

Commit b570075

Browse files
authored
Fix broken tests (#30)
1 parent 94b3055 commit b570075

File tree

6 files changed

+63
-26
lines changed

6 files changed

+63
-26
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ python:
44
- "2.7"
55
env:
66
- CKANVERSION=2.6.3 POSTGISVERSION=2 INTEGRATION_TEST=true
7-
- CKANVERSION=2.7.2 POSTGISVERSION=2
7+
- CKANVERSION=2.7.2 POSTGISVERSION=2 IDM_VERSION=v6
88
- CKANVERSION=2.7.3 POSTGISVERSION=2 INTEGRATION_TEST=true
99
- CKANVERSION=2.8.0 POSTGISVERSION=2 INTEGRATION_TEST=true
1010
services:

bin/travis-build.bash

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ function test_connection {
2424
echo "This is travis-build.bash..."
2525

2626
echo "Installing the packages that CKAN requires..."
27+
sudo apt-get clean
28+
sudo rm -r /var/lib/apt/lists/*
29+
2730
sudo apt-get update -qq
2831
sudo apt-get install solr-jetty
2932

@@ -64,20 +67,23 @@ echo "Installing ckanext-oauth2 and its requirements..."
6467
python setup.py develop
6568

6669
if [ "$INTEGRATION_TEST" = "true" ]; then
67-
sudo sh -c 'echo "\n[ SAN ]\nsubjectAltName=DNS:localhost" >> /etc/ssl/openssl.cnf'
68-
sudo openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \
69-
-subj '/O=API Umbrella/CN=localhost' \
70-
-keyout /etc/ssl/self_signed.key -out /usr/local/share/ca-certificates/self_signed.crt \
71-
-reqexts SAN -extensions SAN
72-
73-
sudo update-ca-certificates
74-
export REQUESTS_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt"
75-
docker network create main
76-
docker run -d --network main -e MYSQL_ROOT_PASSWORD=idm -e MYSQL_ROOT_HOST=% --name mysql mysql/mysql-server:5.7.21
77-
docker run -d -p 443:443 --network main -e DATABASE_HOST=mysql -v "${TRAVIS_BUILD_DIR}/ci/idm-config.js:/opt/fiware-idm/config.js:ro" -v /etc/ssl/self_signed.key:/opt/fiware-idm/certs/self_signed.key:ro -v /usr/local/share/ca-certificates/self_signed.crt:/opt/fiware-idm/certs/self_signed.crt:ro --name idm fiware/idm
78-
79-
# Wait until idm is ready
80-
test_connection 'KeyRock' https://localhost:443
70+
sudo sh -c 'echo "\n[ SAN ]\nsubjectAltName=DNS:localhost" >> /etc/ssl/openssl.cnf'
71+
sudo openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \
72+
-subj '/O=API Umbrella/CN=localhost' \
73+
-keyout /etc/ssl/self_signed.key -out /usr/local/share/ca-certificates/self_signed.crt \
74+
-reqexts SAN -extensions SAN
75+
76+
sudo update-ca-certificates
77+
export REQUESTS_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt"
78+
79+
docker network create main
80+
cd ${TRAVIS_BUILD_DIR}/ci
81+
82+
docker-compose up -d
83+
cd ..
84+
85+
# Wait until idm is ready
86+
test_connection 'KeyRock' http://localhost:3000
8187
fi
8288

8389
echo "travis-build.bash is done."

ci/docker-compose.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: "2"
2+
networks:
3+
main:
4+
external: true
5+
6+
services:
7+
mysql:
8+
image: mysql:5.7
9+
networks:
10+
main:
11+
aliases:
12+
- mysql.idm.docker
13+
environment:
14+
- MYSQL_ROOT_PASSWORD=idm
15+
16+
fiware-idm:
17+
image: fiware/idm:7.6.0
18+
ports:
19+
- "3000:3000"
20+
- "443:443"
21+
networks:
22+
main:
23+
aliases:
24+
- idm.docker
25+
#volumes:
26+
# - /etc/ssl/self_signed.key:/opt/fiware-idm/certs/self_signed.key:ro
27+
# - /usr/local/share/ca-certificates/self_signed.crt:/opt/fiware-idm/certs/self_signed.crt:ro
28+
environment:
29+
- IDM_DB_HOST=mysql.idm.docker

ckanext/oauth2/tests/test_oauth2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_get_token_insecure_enabled(self):
241241
def test_get_token_error(self):
242242
helper = self._helper()
243243
token = {
244-
'error': 'auth_error',
244+
'info': 'auth_error',
245245
'error_description': 'Some description'
246246
}
247247
httpretty.register_uri(httpretty.POST, helper.token_endpoint, body=json.dumps(token))

ckanext/oauth2/tests/test_selenium.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from selenium.webdriver.support.ui import WebDriverWait
3535

3636

37-
IDM_URL = "https://localhost"
37+
IDM_URL = "http://localhost:3000"
3838
FILAB2_MAIL = "[email protected]"
3939
FILAB_PASSWORD = "1234"
4040
PASS_INTEGRATION_TESTS = os.environ.get("INTEGRATION_TEST", "").strip().lower() in ('1', 'true', 'on')
@@ -58,6 +58,7 @@ def setUpClass(cls):
5858
}
5959
url = urljoin(IDM_URL, AUTH_TOKEN_ENDPOINT)
6060
response = requests.post(url, json=body)
61+
print(response.text)
6162

6263
token = response.headers["X-Subject-Token"]
6364

test-fiware.ini

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,22 @@ ckan.tests.functional.test_cache.TestCacheBasics.test_get_cache_expires.expires
3232
ckan.plugins = oauth2
3333

3434
## OAuth2 configuration
35-
ckan.oauth2.register_url = https://localhost/sign_up
36-
ckan.oauth2.reset_url = https://localhost/password/request
37-
ckan.oauth2.edit_url = https://localhost/idm/settings
38-
ckan.oauth2.authorization_endpoint = https://localhost/oauth2/authorize
39-
ckan.oauth2.token_endpoint = https://localhost/oauth2/token
40-
ckan.oauth2.profile_api_url = https://localhost/user
35+
ckan.oauth2.register_url = http://localhost:3000/sign_up
36+
ckan.oauth2.reset_url = http://localhost:3000/password/request
37+
ckan.oauth2.edit_url = http://localhost:3000/idm/settings
38+
ckan.oauth2.authorization_endpoint = http://localhost:3000/oauth2/authorize
39+
ckan.oauth2.token_endpoint = http://localhost:3000/oauth2/token
40+
ckan.oauth2.profile_api_url = http://localhost:3000/user
41+
ckan.oauth2.is_legacy = true
4142
# The following parameters are configured through environment variables
4243
#ckan.oauth2.client_id = 361020fd7cf64456890dd98da88e64f3
4344
#ckan.oauth2.client_secret = edf713bf8a2344139f46a757fadae24f
4445
ckan.oauth2.scope = all_info
4546
ckan.oauth2.rememberer_name = auth_tkt
46-
ckan.oauth2.profile_api_user_field = id
47-
ckan.oauth2.profile_api_fullname_field = displayName
47+
ckan.oauth2.profile_api_user_field = username
48+
ckan.oauth2.profile_api_fullname_field = username
4849
ckan.oauth2.profile_api_mail_field = email
49-
ckan.oauth2.authorization_header = X-Auth-Token
50+
ckan.oauth2.authorization_header = Bearer
5051

5152

5253
#who.config_file = %(here)s/who-fiware.ini

0 commit comments

Comments
 (0)