Browse files

update to tests

updates to cfml interface
  • Loading branch information...
1 parent 12fda1b commit 3ed931574da1741449688ab15b7fc23c4411ffb7 @jmacul2 committed Apr 2, 2012
Showing with 81 additions and 160 deletions.
  1. +1 −3 README.rst
  2. +14 −60 cfmlsentry/interfaces.py
  3. +66 −84 cfmlsentry/templates/sentry/partial/interfaces/cfmlhttp.html
  4. +0 −13 tests/client.cfc
View
4 README.rst
@@ -91,6 +91,4 @@ Resources
---------
* `Bug Tracker <http://github.com/jmacul2/raven-cfml/issues>`_
-* `Code <http://github.com/jmacul2/raven-cfml>`_
-* `Mailing List <https://groups.google.com/group/getsentry>`_
-* `IRC <irc://irc.freenode.net/sentry>`_ (irc.freenode.net, #sentry)
+* `Code <http://github.com/jmacul2/raven-cfml>`_
View
74 cfmlsentry/interfaces.py
@@ -4,58 +4,35 @@
from sentry.interfaces import Interface #@UnresolvedImport
-class ColdFusionHttp(Interface):
+class CFMLHttp(Interface):
score = 100
# methods as defined by http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
METHODS = ('GET', 'POST', 'PUT', 'OPTIONS', 'HEAD', 'DELETE', 'TRACE', 'CONNECT')
def __init__(self, url_path, method=None, form=None, url=None, query_string=None, cookies=None,
sessions=None, application=None, headers=None, cgi=None, **kwargs):
- if form is None:
- form = {}
-
- if method:
- method = method.upper()
-
- assert method in self.METHODS
urlparts = urlparse.urlsplit(url_path)
-
if not query_string:
# define querystring from url
query_string = urlparts.query
-
elif query_string.startswith('?'):
# remove '?' prefix
query_string = query_string[1:]
self.url_path = '%s://%s%s' % (urlparts.scheme, urlparts.netloc, urlparts.path)
- self.method = method
- self.form = form
+
+ if method:
+ self.method = method.upper()
+ assert method in self.METHODS
+
+ self.form = form or {}
self.query_string = query_string
- if application:
- self.application = application
- else:
- self.application = {}
- if url:
- self.url = url
- else:
- self.url = {}
- if sessions:
- self.sessions = sessions
- else:
- self.sessions = {}
- if cookies:
- self.cookies = cookies
- else:
- self.cookies = {}
- # if cookies were [also] included in headers we
- # strip them out
- if headers and 'Cookie' in headers:
- cookies = headers.pop('Cookie')
- if not self.cookies:
- cookies = self.cookies
+ self.application = application or {}
+ self.url = url or {}
+ self.sessions = sessions or {}
+ self.cookies = cookies or {}
self.headers = headers or {}
self.cgi = cgi or {}
@@ -83,40 +60,17 @@ def to_string(self, event):
})
def to_html(self, event):
- form = self.form
- data_is_dict = False
- if self.headers.get('Content-Type') == 'application/x-www-form-urlencoded':
- try:
- form = QueryDict(form)
- except:
- pass
- else:
- data_is_dict = True
-
- # It's kind of silly we store this twice
- cookies = self.cookies or self.headers.pop('Cookie', {})
- cookies_is_dict = isinstance(cookies, dict)
- if not cookies_is_dict:
- try:
- cookies = QueryDict(cookies)
- except:
- pass
- else:
- cookies_is_dict = True
-
return render_to_string('sentry/partial/interfaces/cfmlhttp.html', {
'event': event,
'full_url': '?'.join(filter(bool, [self.url_path, self.query_string])),
'url_path': self.url_path,
'method': self.method,
'url': self.url,
- 'form': form,
- 'data_is_dict': data_is_dict,
+ 'form': self.form,
'query_string': self.query_string,
'application': self.application,
- 'sessions': self.sessions,
- 'cookies': cookies,
- 'cookies_is_dict': cookies_is_dict,
+ 'sessions': self.sessions,
+ 'cookies': self.cookies,
'headers': self.headers,
'cgi': self.cgi,
})
View
150 cfmlsentry/templates/sentry/partial/interfaces/cfmlhttp.html
@@ -28,7 +28,7 @@
<code>{{ query_string|pprint }}</code>
</td>
</tr>
- {% if url %}
+ {% if url %}
<tr>
<th>{% trans "URL Scope:" %}</th>
<td>
@@ -55,113 +55,95 @@
<tr>
<th>{% trans "Form Scope:" %}</th>
<td>
- {% if data_is_dict %}
- {% if form|length > 5 %}
- <a href="#" onclick="return varToggle(this, 'HttpForm')"><span>&#x25b6;</span> {% trans "Form" %}</a>
- {% endif %}
- <table class="table vars" id="vHttpForm"{% if form|length > 5 %} style="display:none;"{% endif %}>
- <colgroup>
- <col style="width:100px;">
- </colgroup>
- <tbody>
- {% for key, value in form.iteritems|as_sorted %}
- <tr>
- <td>{{ key }}</td>
- <td class="code"><pre>{{ value|pprint }}</pre></td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {% else %}
- {% if form|length > 5 %}
- <a href="#" onclick="return varToggle(this, 'HttpForm')"><span>&#x25b6;</span> {% trans "Form" %}</a>
- {% endif %}
- <div id="vHttpForm"{% if form|length > 5 %} style="display:none;"{% endif %}>
- <pre>{{ form|pprint }}</pre>
- </div>
+ {% if form|length > 5 %}
+ <a href="#" onclick="return varToggle(this, 'HttpForm')"><span>&#x25b6;</span> {% trans "Form" %}</a>
{% endif %}
+ <table class="table vars" id="vHttpForm"{% if form|length > 5 %} style="display:none;"{% endif %}>
+ <colgroup>
+ <col style="width:100px;">
+ </colgroup>
+ <tbody>
+ {% for key, value in form.iteritems|as_sorted %}
+ <tr>
+ <td>{{ key }}</td>
+ <td class="code"><pre>{{ value|pprint }}</pre></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
</td>
</tr>
{% endif %}
{% if cookies %}
<tr>
<th>{% trans "Cookie Scope:" %}</th>
<td>
- {% if cookies_is_dict %}
- {% if cookies|length > 5 %}
- <a href="#" onclick="return varToggle(this, 'HttpCookies')"><span>&#x25b6;</span> {% trans "Cookies" %}</a>
- {% endif %}
- <table class="table vars" id="vHttpCookies"{% if cookies|length > 5 %} style="display:none;"{% endif %}>
- <colgroup>
- <col style="width:100px;">
- </colgroup>
- <tbody>
- {% for key, value in cookies.iteritems|as_sorted %}
- <tr>
- <td>{{ key|to_str }}</td>
- <td class="code"><pre>{{ value|pprint }}</pre></td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {% else %}
- {% if cookies|length > 5 %}
- <a href="#" onclick="return varToggle(this, 'HttpCookies')"><span>&#x25b6;</span> {% trans "Cookies" %}</a>
- {% endif %}
- <div id="vHttpCookies"{% if cookies|length > 5 %} style="display:none;"{% endif %}>
- <pre>{{ cookies|pprint }}</pre>
- </div>
+ {% if cookies|length > 5 %}
+ <a href="#" onclick="return varToggle(this, 'HttpCookies')"><span>&#x25b6;</span> {% trans "Cookies" %}</a>
{% endif %}
+ <table class="table vars" id="vHttpCookies"{% if cookies|length > 5 %} style="display:none;"{% endif %}>
+ <colgroup>
+ <col style="width:100px;">
+ </colgroup>
+ <tbody>
+ {% for key, value in cookies.iteritems|as_sorted %}
+ <tr>
+ <td>{{ key|to_str }}</td>
+ <td class="code"><pre>{{ value|pprint }}</pre></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
</td>
</tr>
{% endif %}
- {% if sessions %}
+ {% if sessions %}
<tr>
<th>{% trans "Session Scope:" %}</th>
<td>
- {% if sessions|length > 5 %}
- <a href="#" onclick="return varToggle(this, 'HttpSessions')"><span>&#x25b6;</span> {% trans "Sessions" %}</a>
- {% endif %}
- <table class="table vars" id="vHttpSessions"{% if sessions|length > 5 %} style="display:none;"{% endif %}>
- <colgroup>
- <col style="width:100px;">
- </colgroup>
- <tbody>
- {% for key, value in sessions.iteritems|as_sorted %}
- <tr>
- <td>{{ key|to_str }}</td>
- <td class="code"><pre>{{ value|pprint }}</pre></td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
+ {% if sessions|length > 5 %}
+ <a href="#" onclick="return varToggle(this, 'HttpSessions')"><span>&#x25b6;</span> {% trans "Sessions" %}</a>
+ {% endif %}
+ <table class="table vars" id="vHttpSessions"{% if sessions|length > 5 %} style="display:none;"{% endif %}>
+ <colgroup>
+ <col style="width:100px;">
+ </colgroup>
+ <tbody>
+ {% for key, value in sessions.iteritems|as_sorted %}
+ <tr>
+ <td>{{ key|to_str }}</td>
+ <td class="code"><pre>{{ value|pprint }}</pre></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
</td>
</tr>
{% endif %}
- {% if application %}
+ {% if application %}
<tr>
<th>{% trans "Application Scope:" %}</th>
<td>
- {% if application|length > 5 %}
- <a href="#" onclick="return varToggle(this, 'HttpApplication')"><span>&#x25b6;</span> {% trans "Application" %}</a>
- {% endif %}
- <table class="table vars" id="vHttpApplication"{% if application|length > 5 %} style="display:none;"{% endif %}>
- <colgroup>
- <col style="width:100px;">
- </colgroup>
- <tbody>
- {% for key, value in application.iteritems|as_sorted %}
- <tr>
- <td>{{ key|to_str }}</td>
- <td class="code"><pre>{{ value|pprint }}</pre></td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
+ {% if application|length > 5 %}
+ <a href="#" onclick="return varToggle(this, 'HttpApplication')"><span>&#x25b6;</span> {% trans "Application" %}</a>
+ {% endif %}
+ <table class="table vars" id="vHttpApplication"{% if application|length > 5 %} style="display:none;"{% endif %}>
+ <colgroup>
+ <col style="width:100px;">
+ </colgroup>
+ <tbody>
+ {% for key, value in application.iteritems|as_sorted %}
+ <tr>
+ <td>{{ key|to_str }}</td>
+ <td class="code"><pre>{{ value|pprint }}</pre></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
</td>
</tr>
{% endif %}
- {% if cgi %}
+ {% if cgi %}
<tr>
<th>{% trans "CGI Scope:" %}</th>
<td>
View
13 tests/client.cfc
@@ -1,22 +1,9 @@
<cfcomponent extends="mxunit.framework.TestCase">
- <!--- this will run before every single test in this test case --->
- <!---<cffunction name="setUp" returntype="void" access="public" hint="put things here that you want to run before each test">
- </cffunction>--->
-
- <!--- this will run after every single test in this test case --->
- <!---<cffunction name="tearDown" returntype="void" access="public" hint="put things here that you want to run after each test">
- </cffunction>--->
-
- <!--- this will run once after initialization and before setUp() --->
<cffunction name="beforeTests" returntype="void" access="public" hint="put things here that you want to run before all tests">
<cfset ravenCFC = createObject("component", "lib.client")>
</cffunction>
- <!--- this will run once after all tests have been run --->
- <!---<cffunction name="afterTests" returntype="void" access="public" hint="put things here that you want to run after all tests">
- </cffunction>--->
-
<cffunction name="testHmacSha1" returntype="void" access="public">
<cfset var result = ravenCFC.hmac_sha1('foo', 'bar')>
<cfset assertEquals("46b4ec586117154dacd49d664e5d63fdc88efb51", result, "foo")>

0 comments on commit 3ed9315

Please sign in to comment.