summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZiad Sawalha <gihub@highbridgellc.com>2011-06-15 22:39:09 -0700
committerZiad Sawalha <gihub@highbridgellc.com>2011-06-15 22:39:09 -0700
commit290bbce0aaa0ef8307fb8500c67487549c46c877 (patch)
treeed492eb9c2b72f4eaed4dfcd908d64b5e3606554
parent2f9ad542321828a4bff20f652635b97a848e7e88 (diff)
parent428a893153478174bf73ad46d3e6952d2d3e7dbf (diff)
downloadkeystone-290bbce0aaa0ef8307fb8500c67487549c46c877.tar.gz
keystone-290bbce0aaa0ef8307fb8500c67487549c46c877.tar.xz
keystone-290bbce0aaa0ef8307fb8500c67487549c46c877.zip
Merge pull request #36 from dolph/master
Cleaning up
-rw-r--r--.gitignore2
-rw-r--r--README.md15
-rw-r--r--doc/__init__.py0
-rwxr-xr-xdoc/guide/src/docbkx/identitydevguide.xml10
-rw-r--r--doc/source/__init__.py0
-rw-r--r--examples/__init__.py0
-rw-r--r--examples/echo/__init__.py0
-rw-r--r--keystone/auth_protocols/auth_basic.py15
-rw-r--r--keystone/auth_protocols/auth_openid.py10
-rwxr-xr-xkeystone/auth_protocols/auth_token.py9
-rwxr-xr-xkeystone/common/config.py6
-rwxr-xr-xkeystone/common/exception.py2
-rw-r--r--keystone/common/template.py13
-rwxr-xr-xkeystone/common/wsgi.py2
-rwxr-xr-xkeystone/db/sqlalchemy/api.py20
-rw-r--r--keystone/db/sqlalchemy/models.py2
-rw-r--r--keystone/test/functional/__init__.py0
-rwxr-xr-xkeystone/test/unit/test_authn_v2.py5
-rw-r--r--keystone/test/unit/test_exthandler.py2
-rwxr-xr-xkeystone/test/unit/test_server.py49
-rw-r--r--tools/pip-requires-development2
-rw-r--r--tools/pip-requires-testing2
22 files changed, 83 insertions, 83 deletions
diff --git a/.gitignore b/.gitignore
index f03b2768..164c607c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,9 @@
.project
.project/
.cache/
+.pydevproject
.pydevproject/
+.settings/
keystone.db
.*.swp
*.log
diff --git a/README.md b/README.md
index dddf7cb1..42e35980 100644
--- a/README.md
+++ b/README.md
@@ -78,16 +78,17 @@ By default, configuration parameters are parsed from `etc/keystone.conf`.
## Dependencies
+You may need to prefix your `pip install` commands with `sudo`, depending on your environment.
+
<pre>
-# Show Dependencies
+# Show dependencies
$ cat tools/pip-requires
-# Install Dependencies
-$ sudo pip install -r tools/pip-requires
-
-# Keystone uses the DTest test framework for testing. Install that separately using:
-$ sudo pip install DTest
+# Install dependencies
+$ pip install -r tools/pip-requires
+# Install unit/functional test dependencies
+$ pip install -r tools/pip-requires-testing
</pre>
## Running Keystone
@@ -111,6 +112,8 @@ By default, configuration parameters (such as the IP and port binding for each s
## Running Tests
+Before running tests, ensure you have installed the testing dependencies as described in the Dependencies section above.
+
#### Test data
A set of sample data can be added by running a shell script:
diff --git a/doc/__init__.py b/doc/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/doc/__init__.py
diff --git a/doc/guide/src/docbkx/identitydevguide.xml b/doc/guide/src/docbkx/identitydevguide.xml
index f30cb51b..97023c67 100755
--- a/doc/guide/src/docbkx/identitydevguide.xml
+++ b/doc/guide/src/docbkx/identitydevguide.xml
@@ -69,7 +69,7 @@
<abstract>
<para>
This document is intended for software developers interested
- in developing applications which utilize the Cloud Identity
+ in developing applications that utilize the Cloud Identity
Service for authentication. This document also includes
details on how to integrate services with the Cloud Identity
Service.
@@ -82,7 +82,7 @@
The Keystone Identity Service allows applications to obtain
tokens that can be used to access OpenStack resources. This
document is intended for software developers interested in
- developing applications which utilize the Cloud Identity
+ developing applications that utilize the Cloud Identity
Service for authentication. This document also includes
details on how to integrate services with the Cloud Identity
Service.
@@ -95,7 +95,7 @@
<chapter>
<title>Concepts</title>
<para>
- The Keystone Identity Service has several key concepts that are
+ The Keystone Identity Service has several key concepts which are
important to understand:
</para>
<section>
@@ -109,7 +109,7 @@
<para>
While Keystone supports token-based authentication in this release,
the intention is for it to support additional protocols in the
- future. The desire is to have it be an integration service, and not
+ future. The desire is for it to be an integration service, and not
a full-fledged identity store and management solution.
</para>
</section>
@@ -117,7 +117,7 @@
<title>Tenant</title>
<para>
A container used to group or isolate resources and/or identity
- objects. Depending on the operator, a tenant may map to a customer,
+ objects. Depending on the service operator, a tenant may map to a customer,
account, organization, or project.
</para>
</section>
diff --git a/doc/source/__init__.py b/doc/source/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/doc/source/__init__.py
diff --git a/examples/__init__.py b/examples/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/examples/__init__.py
diff --git a/examples/echo/__init__.py b/examples/echo/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/examples/echo/__init__.py
diff --git a/keystone/auth_protocols/auth_basic.py b/keystone/auth_protocols/auth_basic.py
index 9c9bae6f..b2631614 100644
--- a/keystone/auth_protocols/auth_basic.py
+++ b/keystone/auth_protocols/auth_basic.py
@@ -31,11 +31,14 @@ This is an Auth component as per: http://wiki.openstack.org/openstack-authn
"""
-from paste.deploy import loadapp
+import os
+import urlparse
import eventlet
from eventlet import wsgi
-import os
-from webob.exc import HTTPUnauthorized, HTTPInternalServerError
+from paste.deploy import loadapp
+from keystone.common.bufferedhttp import http_connect_raw as http_connect
+from webob.exc import Request, Response
+from webob.exc import HTTPUnauthorized
PROTOCOL_NAME = "Basic Authentication"
@@ -100,7 +103,7 @@ class AuthProtocol(object):
# Claims were provided - validate them
import base64
auth_header = env['HTTP_AUTHORIZATION']
- auth_type, encoded_creds = auth_header.split(None, 1)
+ _auth_type, encoded_creds = auth_header.split(None, 1)
user, password = base64.b64decode(encoded_creds).split(':', 1)
if not self.validateCreds(user, password):
#Claims were rejected
@@ -148,8 +151,8 @@ class AuthProtocol(object):
def validateCreds(self, username, password):
#stub for password validation.
- import ConfigParser
- import hashlib
+ # import ConfigParser
+ # import hashlib
#usersConfig = ConfigParser.ConfigParser()
#usersConfig.readfp(open('/etc/openstack/users.ini'))
#password = hashlib.sha1(password).hexdigest()
diff --git a/keystone/auth_protocols/auth_openid.py b/keystone/auth_protocols/auth_openid.py
index 350d5c46..1586537a 100644
--- a/keystone/auth_protocols/auth_openid.py
+++ b/keystone/auth_protocols/auth_openid.py
@@ -17,6 +17,13 @@
# limitations under the License.
# Not Yet PEP8 standardized
+import os
+import urlparse
+import eventlet
+from eventlet import wsgi
+from keystone.common.bufferedhttp import http_connect_raw as http_connect
+from webob.exc import Request, Response
+from paste.deploy import loadapp
"""
OPENID AUTH MIDDLEWARE - STUB
@@ -75,13 +82,14 @@ class AuthProtocol(object):
env['HTTP_AUTHORIZATION'] = "Basic %s" % self.service_pass
return self.app(env, custom_start_response)
+ proxy_headers = []
proxy_headers['AUTHORIZATION'] = "Basic %s" % self.service_pass
# We are forwarding to a remote service (no downstream WSGI app)
req = Request(proxy_headers)
parsed = urlparse(req.url)
conn = http_connect(self.service_host, self.service_port, \
req.method, parsed.path, \
- proxy_headers,\
+ proxy_headers, \
ssl=(self.service_protocol == 'https'))
resp = conn.getresponse()
data = resp.read()
diff --git a/keystone/auth_protocols/auth_token.py b/keystone/auth_protocols/auth_token.py
index 95d8fa2a..1734dd3c 100755
--- a/keystone/auth_protocols/auth_token.py
+++ b/keystone/auth_protocols/auth_token.py
@@ -57,7 +57,6 @@ import httplib
import json
import os
from paste.deploy import loadapp
-import sys
from urlparse import urlparse
from webob.exc import HTTPUnauthorized, HTTPUseProxy
from webob.exc import Request, Response
@@ -98,7 +97,7 @@ class AuthProtocol(object):
def _init_protocol(self, app, conf):
""" Protocol specific initialization """
- # where to find the auth service (we use this to validate tokens)
+ # where to find the auth service (we use this to validate tokens)
self.auth_host = conf.get('auth_host')
self.auth_port = int(conf.get('auth_port'))
self.auth_protocol = conf.get('auth_protocol', 'https')
@@ -236,7 +235,7 @@ class AuthProtocol(object):
conn = http_connect(self.auth_host, self.auth_port, 'GET',
'/v2.0/tokens/%s' % claims, headers=headers)
resp = conn.getresponse()
- data = resp.read()
+ # data = resp.read()
conn.close()
if not str(resp.status).startswith('20'):
@@ -271,8 +270,8 @@ class AuthProtocol(object):
token_info = json.loads(data)
#TODO(Ziad): make this more robust
#first_group = token_info['auth']['user']['groups']['group'][0]
- roles =[]
- role_refs =token_info["auth"]["user"]["roleRefs"]
+ roles = []
+ role_refs = token_info["auth"]["user"]["roleRefs"]
if role_refs != None:
for role_ref in role_refs:
roles.append(role_ref["roleId"])
diff --git a/keystone/common/config.py b/keystone/common/config.py
index 34281192..71925239 100755
--- a/keystone/common/config.py
+++ b/keystone/common/config.py
@@ -20,18 +20,12 @@
Routines for configuring OpenStack Service
"""
-import ConfigParser
-import logging
import logging.config
-import logging.handlers
import optparse
import os
from paste import deploy
-import re
import sys
-import keystone.common.exception as exception
-
DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
diff --git a/keystone/common/exception.py b/keystone/common/exception.py
index fb64220d..ee4f4392 100755
--- a/keystone/common/exception.py
+++ b/keystone/common/exception.py
@@ -22,8 +22,6 @@ OpenStack-type exceptions. SHOULD include dedicated exception logging.
"""
import logging
-import sys
-import traceback
class ProcessExecutionError(IOError):
diff --git a/keystone/common/template.py b/keystone/common/template.py
index f8412d62..23910d85 100644
--- a/keystone/common/template.py
+++ b/keystone/common/template.py
@@ -45,6 +45,7 @@ import re
import os
import functools
import time
+import tokenize
from webob import Response
import keystone.logic.types.fault as fault
@@ -124,7 +125,7 @@ class BaseTemplate(object):
class SimpleTemplate(BaseTemplate):
- blocks = ('if','elif','else','try','except','finally','for','while','with','def','class')
+ blocks = ('if', 'elif', 'else', 'try', 'except', 'finally', 'for', 'while', 'with', 'def', 'class')
dedent_blocks = ('elif', 'else', 'except', 'finally')
def prepare(self, escape_func=cgi.escape, noescape=False):
@@ -163,7 +164,7 @@ class SimpleTemplate(BaseTemplate):
try:
tokens = list(tokenize.generate_tokens(iter(line).next))
except tokenize.TokenError:
- return line.rsplit('#',1) if '#' in line else (line, '')
+ return line.rsplit('#', 1) if '#' in line else (line, '')
for token in tokens:
if token[0] == tokenize.COMMENT:
start, end = token[2][1], token[3][1]
@@ -181,7 +182,7 @@ class SimpleTemplate(BaseTemplate):
cline += '_str(%s)' % value
elif token == 'CMD':
cline += '_escape(%s)' % value
- cline += ', '
+ cline += ', '
cline = cline[:-2] + '\\\n'
cline = cline[:-2]
if cline[:-1].endswith('\\\\\\\\\\n'):
@@ -201,9 +202,9 @@ class SimpleTemplate(BaseTemplate):
if lineno <= 2:
m = re.search(r"%.*coding[:=]\s*([-\w\.]+)", line)
if m: self.encoding = m.group(1)
- if m: line = line.replace('coding','coding (removed)')
+ if m: line = line.replace('coding', 'coding (removed)')
if line.strip()[:2].count('%') == 1:
- line = line.split('%',1)[1].lstrip() # Full line following the %
+ line = line.split('%', 1)[1].lstrip() # Full line following the %
cline = split_comment(line)[0].strip()
cmd = re.split(r'[^a-zA-Z0-9_]', cline)[0]
flush() ##encodig (TODO: why?)
@@ -319,7 +320,7 @@ def template(tpl, template_adapter=SimpleTemplate, **kwargs):
You can use a name, a filename or a template string as first parameter.
'''
if tpl not in TEMPLATES or DEBUG:
- settings = kwargs.get('template_settings',{})
+ settings = kwargs.get('template_settings', {})
lookup = kwargs.get('template_lookup', TEMPLATE_PATH)
if isinstance(tpl, template_adapter):
TEMPLATES[tpl] = tpl
diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py
index 1f48137c..b89732f9 100755
--- a/keystone/common/wsgi.py
+++ b/keystone/common/wsgi.py
@@ -26,10 +26,8 @@ import logging
import sys
import datetime
-import eventlet
import eventlet.wsgi
eventlet.patcher.monkey_patch(all=False, socket=True)
-import routes
import routes.middleware
import webob.dec
import webob.exc
diff --git a/keystone/db/sqlalchemy/api.py b/keystone/db/sqlalchemy/api.py
index 9edcc0e6..d3146913 100755
--- a/keystone/db/sqlalchemy/api.py
+++ b/keystone/db/sqlalchemy/api.py
@@ -689,14 +689,6 @@ def user_delete_tenant(id, tenant_id, session=None):
session.delete(group_user)
-def user_get_by_tenant(user_id, tenant_id, session=None):
- if not session:
- session = get_session()
- result = session.query(models.User).filter_by(id=user_id,
- tenant_id=tenant_id).first()
- return result
-
-
def users_get_by_tenant(user_id, tenant_id, session=None):
if not session:
session = get_session()
@@ -867,7 +859,7 @@ def users_get_page(marker, limit, session=None):
return session.query(user).\
order_by("id").limit(limit).all()
-def users_get_page_markers(marker, limit,\
+def users_get_page_markers(marker, limit, \
session=None):
if not session:
session = get_session()
@@ -930,7 +922,7 @@ def users_get_by_tenant_get_page(tenant_id, marker, limit, session=None):
"id").limit(limit).all()
-def users_get_by_tenant_get_page_markers(tenant_id, marker, limit,\
+def users_get_by_tenant_get_page_markers(tenant_id, marker, limit, \
session=None):
if not session:
session = get_session()
@@ -1014,11 +1006,11 @@ def groups_get_by_user_get_page_markers(user_id, marker, limit, session=None):
session = get_session()
uga = aliased(models.UserGroupAssociation)
group = aliased(models.Group)
- first, firstassoc = session.query(group, uga).\
+ first, _firstassoc = session.query(group, uga).\
join((uga, uga.group_id == group.id)).\
filter(uga.user_id == user_id).\
order_by(group.id).first()
- last, lastassoc = session.query(group, uga).\
+ last, _lastassoc = session.query(group, uga).\
join((uga, uga.group_id == group.id)).\
filter(uga.user_id == user_id).\
order_by(group.id.desc()).first()
@@ -1045,12 +1037,12 @@ def groups_get_by_user_get_page_markers(user_id, marker, limit, session=None):
if next_len == 0:
next = last
else:
- for t, a in next:
+ for t, _a in next:
next = t
if prev_len == 0:
prev = first
else:
- for t, a in prev:
+ for t, _a in prev:
prev = t
if first.id == marker:
prev = None
diff --git a/keystone/db/sqlalchemy/models.py b/keystone/db/sqlalchemy/models.py
index 79d3dc3a..d9b3af63 100644
--- a/keystone/db/sqlalchemy/models.py
+++ b/keystone/db/sqlalchemy/models.py
@@ -15,7 +15,7 @@
# limitations under the License.
# Not Yet PEP8 standardized
-from sqlalchemy import create_engine, Column, String, Integer, ForeignKey,\
+from sqlalchemy import Column, String, Integer, ForeignKey, \
UniqueConstraint, Boolean
from sqlalchemy import DateTime
from sqlalchemy.exc import IntegrityError
diff --git a/keystone/test/functional/__init__.py b/keystone/test/functional/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/keystone/test/functional/__init__.py
diff --git a/keystone/test/unit/test_authn_v2.py b/keystone/test/unit/test_authn_v2.py
index af9d725b..92134584 100755
--- a/keystone/test/unit/test_authn_v2.py
+++ b/keystone/test/unit/test_authn_v2.py
@@ -17,9 +17,8 @@
import json
import logging
-from keystone import server
-from test.unit import base
-from test.unit.decorators import jsonify, xmlify
+from keystone.test.unit import base
+from keystone.test.unit.decorators import jsonify, xmlify
logger = logging.getLogger('test.unit.test_authn_v2')
diff --git a/keystone/test/unit/test_exthandler.py b/keystone/test/unit/test_exthandler.py
index 4379e03f..30a61f98 100644
--- a/keystone/test/unit/test_exthandler.py
+++ b/keystone/test/unit/test_exthandler.py
@@ -19,7 +19,7 @@ import sys
# Need to access identity module
sys.path.append(os.path.abspath(os.path.join(
os.getcwd(), '..', '..', 'keystone')))
-from queryext.exthandler import UrlExtensionFilter
+from keystone.queryext.exthandler import UrlExtensionFilter
import unittest
diff --git a/keystone/test/unit/test_server.py b/keystone/test/unit/test_server.py
index 031015a2..7501b8ae 100755
--- a/keystone/test/unit/test_server.py
+++ b/keystone/test/unit/test_server.py
@@ -5,8 +5,8 @@ import json
sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__),
'..', '..', '..', '..', '..', 'keystone')))
-
-from keystone import server
+
+from keystone import utils
import keystone.logic.types.auth as auth
import keystone.logic.types.fault as fault
@@ -14,7 +14,6 @@ from StringIO import StringIO
from datetime import date
from lxml import etree
from webob import Request
-from webob import Response
class TestServer(unittest.TestCase):
'''Unit tests for server.py.'''
@@ -25,19 +24,19 @@ class TestServer(unittest.TestCase):
def setUp(self):
environ = {'wsgi.url_scheme': 'http'}
self.request = Request(environ)
- self.auth_data = auth.AuthData(auth.Token(date.today(),"2231312"), auth.User("username","12345",auth.Groups([],[])))
+ self.auth_data = auth.AuthData(auth.Token(date.today(), "2231312"), auth.User("username", "12345", auth.Groups([], [])))
#def tearDown(self):
def test_is_xml_response(self):
- self.assertFalse(server.is_xml_response(self.request))
+ self.assertFalse(utils.is_xml_response(self.request))
self.request.headers["Accept"] = "application/xml"
- self.request.content_type="application/json"
- self.assertTrue(server.is_xml_response(self.request))
+ self.request.content_type = "application/json"
+ self.assertTrue(utils.is_xml_response(self.request))
def test_send_result_xml(self):
self.request.headers["Accept"] = "application/xml"
- response = server.send_result(200,self.request,self.auth_data);
+ response = utils.send_result(200, self.request, self.auth_data);
self.assertTrue(response.headers['content-type'] == "application/xml; charset=UTF-8")
xml = etree.fromstring(response.unicode_body)
@@ -45,42 +44,42 @@ class TestServer(unittest.TestCase):
user = xml.find("{http://docs.openstack.org/identity/api/v2.0}user")
token = xml.find("{http://docs.openstack.org/identity/api/v2.0}token")
- self.assertTrue(user.get("username"),"username")
- self.assertTrue(user.get("tenantId"),'12345');
- self.assertTrue(token.get("id"),'2231312');
- self.assertTrue(token.get("expires"),date.today());
+ self.assertTrue(user.get("username"), "username")
+ self.assertTrue(user.get("tenantId"), '12345');
+ self.assertTrue(token.get("id"), '2231312');
+ self.assertTrue(token.get("expires"), date.today());
def test_send_result_json(self):
self.request.headers["Accept"] = "application/json"
- response = server.send_result(200,self.request,self.auth_data);
+ response = utils.send_result(200, self.request, self.auth_data);
self.assertTrue(response.headers['content-type'] == "application/json; charset=UTF-8")
dict = json.loads(response.unicode_body)
- self.assertTrue(dict['auth']['user']['username'],'username');
- self.assertTrue(dict['auth']['user']['tenantId'],'12345');
- self.assertTrue(dict['auth']['token']['id'],'2231312');
- self.assertTrue(dict['auth']['token']['expires'],date.today());
+ self.assertTrue(dict['auth']['user']['username'], 'username');
+ self.assertTrue(dict['auth']['user']['tenantId'], '12345');
+ self.assertTrue(dict['auth']['token']['id'], '2231312');
+ self.assertTrue(dict['auth']['token']['expires'], date.today());
def test_get_auth_token(self):
- self.request.headers["X-Auth-Token"]="Test token"
- self.assertTrue(server.get_auth_token(self.request),"Test Token")
+ self.request.headers["X-Auth-Token"] = "Test token"
+ self.assertTrue(utils.get_auth_token(self.request), "Test Token")
def test_get_normalized_request_content_exception(self):
- self.assertRaises(fault.IdentityFault,server.get_normalized_request_content,None,self.request)
+ self.assertRaises(fault.IdentityFault, utils.get_normalized_request_content, None, self.request)
def test_get_normalized_request_content_xml(self):
- self.request.environ["CONTENT_TYPE"]="application/xml"
- pwd_cred = auth.PasswordCredentials("username","password","1")
+ self.request.environ["CONTENT_TYPE"] = "application/xml"
+ pwd_cred = auth.PasswordCredentials("username", "password", "1")
body = '<?xml version="1.0" encoding="UTF-8"?> \
<passwordCredentials \
xmlns="http://docs.openstack.org/identity/api/v2.0" \
password="secret" username="disabled" \
/>'
- str=StringIO()
+ str = StringIO()
str.write(body)
- self.request.environ["wsgi.input"]=str
+ self.request.environ["wsgi.input"] = str
self.request.environ["CONTENT_LENGTH"] = str.len
#TODO: I THINK THIS belongs in a test for auth.py.
if __name__ == '__main__':
- unittest.main() \ No newline at end of file
+ unittest.main()
diff --git a/tools/pip-requires-development b/tools/pip-requires-development
new file mode 100644
index 00000000..5e9bc650
--- /dev/null
+++ b/tools/pip-requires-development
@@ -0,0 +1,2 @@
+Sphinx # required to build documentation
+coverage # computes code coverage percentages \ No newline at end of file
diff --git a/tools/pip-requires-testing b/tools/pip-requires-testing
new file mode 100644
index 00000000..49919045
--- /dev/null
+++ b/tools/pip-requires-testing
@@ -0,0 +1,2 @@
+webtest
+DTest \ No newline at end of file