# Path: restkit/filters.py
# class BasicAuth(object):
#     """ Simple filter to manage basic authentification"""
#     
#     def __init__(self, username, password):
#         self.credentials = (username, password)
#     
#     def on_request(self, request):
#         encode = base64.b64encode("%s:%s" % self.credentials)
#         request.headers['Authorization'] = 'Basic %s' %  encode


import cgi
import imghdr
import os
import socket
import threading
import Queue
import urlparse
import sys
import tempfile
import time
import t
from restkit.filters import BasicAuth
        t.eq(r.status_int, 200)
        t.eq(int(r.body_string()), l)
    

@t.client_request('/large')
def test_017(u, c):
    r = c.request(u, 'POST', body=LONG_BODY_PART)
    t.eq(r.status_int, 200)
    t.eq(int(r['content-length']), len(LONG_BODY_PART))
    t.eq(r.body_string(), LONG_BODY_PART)
       


def test_0018():
    for i in range(10):
        t.client_request('/large')(test_017)
        
@t.client_request('/')
def test_019(u, c):
    r = c.request(u, 'PUT', body="test")
    t.eq(r.body_string(), "test")
    
    
@t.client_request('/auth')
def test_020(u, c):
    c.filters = [BasicAuth("test", "test")]
    c.load_filters()
    r = c.request(u)
    t.eq(r.status_int, 200)
    

# Path: restkit/filters.py
# class BasicAuth(object):
#     """ Simple filter to manage basic authentification"""
#     
#     def __init__(self, username, password):
#         self.credentials = (username, password)
#     
#     def on_request(self, request):
#         encode = base64.b64encode("%s:%s" % self.credentials)
#         request.headers['Authorization'] = 'Basic %s' %  encode


# Path: tests/004-test-client.py
import cgi
import imghdr
import os
import socket
import threading
import Queue
import urlparse
import sys
import tempfile
import time
import t
from restkit.filters import BasicAuth

        t.eq(r.status_int, 200)
        t.eq(int(r.body_string()), l)
    

@t.client_request('/large')
def test_017(u, c):
    r = c.request(u, 'POST', body=LONG_BODY_PART)
    t.eq(r.status_int, 200)
    t.eq(int(r['content-length']), len(LONG_BODY_PART))
    t.eq(r.body_string(), LONG_BODY_PART)
       


def test_0018():
    for i in range(10):
        t.client_request('/large')(test_017)
        
@t.client_request('/')
def test_019(u, c):
    r = c.request(u, 'PUT', body="test")
    t.eq(r.body_string(), "test")
    
    
@t.client_request('/auth')
def test_020(u, c):
    c.filters = [BasicAuth("test", "test")]
    c.load_filters()
    r = c.request(u)
    t.eq(r.status_int, 200)
    

    c.filters = [BasicAuth("test", "test2")]