-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Code coverage - Changed plugin directory - Added new LDAP authentication test Signed-off-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
6f99b66
commit e6b2435
Showing
10 changed files
with
174 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
os: linux | ||
sudo: required | ||
dist: trusty | ||
|
||
cache: pip | ||
language: python | ||
python: | ||
- 2.7 | ||
- 3.6 | ||
os: linux | ||
sudo: required | ||
dist: trusty | ||
|
||
install: | ||
- chmod +x .travis/install.sh | ||
- .travis/install.sh | ||
- ".travis/install.sh" | ||
|
||
before_script: | ||
- export PYTHONPATH=$PYTHONPATH:$(pwd) | ||
|
||
script: | ||
- chmod +x .travis/run.sh | ||
- .travis/run.sh | ||
- ".travis/run.sh" | ||
|
||
after_success: | ||
- codecov | ||
|
||
deploy: | ||
provider: pypi | ||
user: uilianries | ||
password: | ||
secure: yGrLzRVZTkV9Sax7fEgJjxFBnkocZGwE5wtHy4hzaByI7SeUO3nKvDGiYESw0OnV0ri7LIZ8CauvH9ltyAkLiLZH3saV0z5c5l2f34R5vy3PoEgk1FG6Wv/HBVnYHY3d1IfzjwK9LZintIMkFkt7WYWgOR+FtaFUip81pAW8EbNe36RHms44dL74oZbvHH5fUBXIxwOxP5L+6+H3tob4YQKlP59GgxeGhv8QfpHHMEHDiwbBDeooV1aD4o1VXc2Aw/6n1rnGRELUaxz+5XwnhW5Uw+bMS6sG7GwQb00R/AOCWa4tT+fo643Hh8xtWb1dfNh+0Qcy4gkzZ7Ebwinz+skEmiS7zMWBhnuNJaJicKvUMHgOoB3Q0sqsFaEXYVVGXVh5ZTFYfQKNdASXg8G/A0cLRyFB1JKGi3McBTMs7cjvLhA3E1XZifP1S/Lx3u4tJojS8ZWgDpy9g5DvD4cefO8UZkyzO2r0Prh10EA+Z7EFn+M/hHdwahd++OzEV/L0/SAOUze1ki/SKHYdICUd3P/lqzCKF4eOadEwuqA9Rgj5Yk9A8w1adImhxc20rfIOPUk5vqReXagxg1z4pDcHa7rsmkN/XceIed/pU16H4X9IkQoXFiLjo7svm5Bak5MZl9M7KefiOLusGVOOqmIb7GhVKR4DSQPqA/SDMwWIcJY= | ||
secure: m53R1xVryG63qFQ/so9EhWFRLmnmxHIImsTR03mGonKrhFTl31pdP8YAbDAaEVx+SttKNeDZH9D5fS1RaDPA0h3RZbP8nZ6nz08kUV0chaF/bQc2j5Za3XtLEqd8ZUxudQlZdqQTfRnnyXIBP9AjRo2eTRhDl7qQvwWwLxAxic3Bl/yYFrgTm8I6bsi6BJ4vOaVGfiSrItXny9oEfiPpnG5+tBmhPm910QlZxaiBIe2mfkmxRFx3UaGruXPWQ5C6g2yt++ixixKEUfMED6A1t63vBdDGTAal+iKU3Oc10afr6yi7SpCRTgDOqEXqsofqVU/llha57yKKasitI24+8eoySFVoS/r3ziW3DZTivZ/Tay4bXTQYg2ZZCDLxYGxrR+CVvz8jQPaJlN98M7kc+36h378/3cJ9CUQ3658SCNWb6JjcrTnzXjwKYUv3mo7QB5ZlRoZNHuGriKGE1XU+FZkNPt/ixwZDEVwRAD1O1ag9nmHHo1okSX9G8FrQjKixSz8jY8lAAcFizIx8s7GUa1X+O9aBy5/lnMRXU4cgV8y0NdLjHnvezz8BYegYGM8KmnpVqiEyfyPCeZhq7dNY9C0v93BeosfPsZ5boY6vK9WEYDPQrUM3fK9wA1loPhaNWHvVrg6MEwxBKHvjA/FAJTgPDwNf689AhbfMbY7wYZY= | ||
on: | ||
tags: true | ||
condition: "$TRAVIS_PYTHON_VERSION = '2.7'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pyldap>=2.4.28 | ||
configparser>=3.5.0 | ||
configparser>=3.5.0 | ||
conan>=0.24.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
"""Virtual LDAP configuration | ||
""" | ||
from tempfile import NamedTemporaryFile | ||
from os import environ, path | ||
|
||
|
||
class ConfigurationFile(object): | ||
test_valid_config = ''' | ||
[ldap] | ||
# LDAP server address | ||
host: ldap://ldap.forumsys.com | ||
# Distinguished name (DN) of the entry | ||
distinguished_name: cn=$username,dc=example,dc=com | ||
''' | ||
|
||
test_wrong_config = ''' | ||
[ldap] | ||
# LDAP server address | ||
host: ldap://ldap.forumsys | ||
# Distinguished name (DN) of the entry | ||
distinguished_name: cn=$username,dc=example,dc=com | ||
''' | ||
|
||
test_invalid_config = ''' | ||
[server] | ||
# LDAP server address | ||
host: ldap://ldap.forumsys.com | ||
# Distinguished name (DN) of the entry | ||
distinguished_name: cn=$username,dc=example,dc=com | ||
''' | ||
|
||
@staticmethod | ||
def create_config_file(file_content): | ||
temp_file = NamedTemporaryFile(prefix="ldap-authentication-", delete=False) | ||
with open(temp_file.name, 'w') as file: | ||
file.write(file_content) | ||
environ["CONAN_LDAP_AUTHENTICATION_CONFIG_FILE"] = temp_file.name | ||
|
||
@staticmethod | ||
def create_valid_config(): | ||
ConfigurationFile.create_config_file(ConfigurationFile.test_valid_config) | ||
|
||
@staticmethod | ||
def create_wrong_config(): | ||
ConfigurationFile.create_config_file(ConfigurationFile.test_wrong_config) | ||
|
||
@staticmethod | ||
def create_invalid_config(): | ||
ConfigurationFile.create_config_file(ConfigurationFile.test_wrong_config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import unittest | ||
import subprocess | ||
import os | ||
import signal | ||
import time | ||
from conans.client.conan_api import ConanAPIV1 | ||
import conans.errors | ||
from conan.test.configuration_file import ConfigurationFile | ||
"""Validate LDAP authentication by Conan Server | ||
""" | ||
|
||
class TestConanAuthentication(unittest.TestCase): | ||
conan_server_name = 'conan_server' | ||
pid = 0 | ||
conan_api = None | ||
conan_server_conf_data = """ | ||
[server] | ||
jwt_secret: MnpuzsExftskYGOMgaTYDKfw | ||
jwt_expire_minutes: 120 | ||
ssl_enabled: False | ||
port: 9300 | ||
public_port: | ||
host_name: localhost | ||
store_adapter: disk | ||
authorize_timeout: 1800 | ||
disk_storage_path: ~/.conan_server/data | ||
disk_authorize_timeout: 1800 | ||
updown_secret: NyiSWNWnwumTVpGpoANuyyhR | ||
custom_authenticator: ldap_authentication | ||
[write_permissions] | ||
[read_permissions] | ||
*/*@*/*: * | ||
# Authentication type: [raw, ldap] | ||
[auth] | ||
type: users | ||
[users] | ||
""" | ||
|
||
@classmethod | ||
def setUpClass(TestConanAuthentication): | ||
conan_server_conf_path = os.path.join(os.path.expanduser('~'), '.conan_server', 'server.conf') | ||
if not os.path.exists(conan_server_conf_path): | ||
with open(conan_server_conf_path, 'w') as file: | ||
file.write(TestConanAuthentication.conan_server_conf_data) | ||
TestConanAuthentication.pid = subprocess.Popen(TestConanAuthentication.conan_server_name, stdout=subprocess.PIPE).pid | ||
time.sleep(3) | ||
TestConanAuthentication.conan_api, _, _ = ConanAPIV1.factory() | ||
TestConanAuthentication.conan_api.remote_add(remote="local", url="http://localhost:9300/") | ||
|
||
@classmethod | ||
def tearDownClass(TestConanAuthentication): | ||
os.kill(TestConanAuthentication.pid, signal.SIGTERM) | ||
TestConanAuthentication.conan_api.remote_remove(remote="local") | ||
|
||
def test_valid_ldap_login(self): | ||
TestConanAuthentication.conan_api.user(name="read-only-admin", password="password", remote="local") | ||
|
||
def test_invalid_ldap_login(self): | ||
try: | ||
TestConanAuthentication.conan_api.user(name="read-only-admin", password="foobar", remote="local") | ||
self.fail() | ||
except conans.errors.AuthenticationException as exception: | ||
self.assertEqual(str(exception), 'Wrong user or password. [Remote: local]') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters