Ejemplo n.º 1
0
def step_create_a_user(context):
    data = apply_placeholders(context, context.text)
    with context.app.mail.record_messages() as outbox:
        context.response = context.client.post(get_prefixed_url(context.app, '/users'),
                                               data=data, headers=context.headers)
        expect_status_in(context.response, (200, 201))
        assert len(outbox) == 1
        context.email = outbox[0]
Ejemplo n.º 2
0
def step_create_a_user(context):
    data = apply_placeholders(context, context.text)
    with context.app.mail.record_messages() as outbox:
        context.response = context.client.post(get_prefixed_url(context.app, '/users'),
                                               data=data, headers=context.headers)
        expect_status_in(context.response, (200, 201))
        assert len(outbox) == 1
        context.email = outbox[0]
Ejemplo n.º 3
0
def we_reset_password_for_user(context):
    start_reset_password_for_user(context)
    expect_status_in(context.response, (200, 201))

    auth_data = {'username': '******', 'password': '******'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    context.response = context.client.post(get_prefixed_url(context.app, '/auth'), data=auth_data, headers=headers)
    expect_status_in(context.response, (200, 201))
Ejemplo n.º 4
0
def we_post_to_reset_password_it_fails(context):
    data = {'email': '*****@*****.**'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    with context.app.mail.record_messages() as outbox:
        context.response = context.client.post(get_prefixed_url(context.app, '/reset_user_password'),
                                               data=data, headers=headers)
        expect_status_in(context.response, (200, 201))
        assert len(outbox) == 0
Ejemplo n.º 5
0
def we_reset_password_for_user(context):
    start_reset_password_for_user(context)
    expect_status_in(context.response, (200, 201))

    auth_data = {'username': '******', 'password': '******'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    context.response = context.client.post(get_prefixed_url(context.app, '/auth'), data=auth_data, headers=headers)
    expect_status_in(context.response, (200, 201))
Ejemplo n.º 6
0
def we_post_to_reset_password_it_fails(context):
    data = {'email': '*****@*****.**'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    with context.app.mail.record_messages() as outbox:
        context.response = context.client.post(get_prefixed_url(context.app, '/reset_user_password'),
                                               data=data, headers=headers)
        expect_status_in(context.response, (200, 201))
        assert len(outbox) == 0
Ejemplo n.º 7
0
def we_reset_password_for_user(context):
    data = {'token': context.token, 'password': '******'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    context.response = context.client.post('/reset_user_password', data=data, headers=headers)
    expect_status_in(context.response, (200, 201))

    auth_data = {'username': '******', 'password': '******'}
    context.response = context.client.post('/auth', data=auth_data, headers=headers)
    expect_status_in(context.response, (200, 201))
Ejemplo n.º 8
0
def we_reset_password_for_user(context):
    data = {'token': context.token, 'password': '******'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    context.response = context.client.post('/reset_user_password',
                                           data=data,
                                           headers=headers)
    expect_status_in(context.response, (200, 201))

    auth_data = {'username': '******', 'password': '******'}
    context.response = context.client.post('/auth',
                                           data=auth_data,
                                           headers=headers)
    expect_status_in(context.response, (200, 201))
Ejemplo n.º 9
0
def we_post_to_reset_password(context):
    data = {'email': '*****@*****.**'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    with context.app.mail.record_messages() as outbox:
        context.response = context.client.post('/reset_user_password', data=data, headers=headers)
        expect_status_in(context.response, (200, 201))
        assert len(outbox) == 1
        assert outbox[0].subject == "Reset password"
        email_text = outbox[0].body
        assert "24" in email_text
        words = re.split('\W+', email_text)
        token = words[words.index("token") + 1]
        assert token
        context.token = token
Ejemplo n.º 10
0
def we_post_to_reset_password(context):
    data = {'email': '*****@*****.**'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    with context.app.mail.record_messages() as outbox:
        context.response = context.client.post('/reset_user_password',
                                               data=data,
                                               headers=headers)
        expect_status_in(context.response, (200, 201))
        assert len(outbox) == 1
        assert outbox[0].subject == "Reset password"
        email_text = outbox[0].body
        assert "24" in email_text
        words = re.split('\W+', email_text)
        token = words[words.index("token") + 1]
        assert token
        context.token = token
Ejemplo n.º 11
0
def we_post_to_reset_password(context):
    data = {'email': '*****@*****.**'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    with context.app.mail.record_messages() as outbox:
        context.response = context.client.post(get_prefixed_url(context.app, '/reset_user_password'),
                                               data=data, headers=headers)
        expect_status_in(context.response, (200, 201))
        assert len(outbox) == 1
        assert outbox[0].subject == "Reset password"
        email_text = outbox[0].body
        assert "24" in email_text
        words = email_text.split()
        url = urlparse(words[words.index("link") + 1])
        token = url.fragment.split('token=')[-1]
        assert token
        context.token = token
Ejemplo n.º 12
0
def we_post_to_reset_password(context):
    data = {'email': '*****@*****.**'}
    headers = [('Content-Type', 'multipart/form-data')]
    headers = unique_headers(headers, context.headers)
    with context.app.mail.record_messages() as outbox:
        context.response = context.client.post(get_prefixed_url(context.app, '/reset_user_password'),
                                               data=data, headers=headers)
        expect_status_in(context.response, (200, 201))
        assert len(outbox) == 1
        assert outbox[0].subject == "Reset password"
        email_text = outbox[0].body
        assert "24" in email_text
        words = email_text.split()
        url = urlparse(words[words.index("link") + 1])
        token = url.fragment.split('token=')[-1]
        assert token
        context.token = token
Ejemplo n.º 13
0
def assert_ok(response):
    """Assert we get ok status within api response."""
    expect_status_in(response, (200, 201))
    expect_json_contains(response, {'_status': 'OK'})
Ejemplo n.º 14
0
def assert_200(response):
    """Assert we get status code 200."""
    expect_status_in(response, (200, 201))
Ejemplo n.º 15
0
def assert_ok(response):
    """Assert we get ok status within api response."""
    expect_status_in(response, (200, 201))
    expect_json_contains(response, {'_status': 'OK'})
Ejemplo n.º 16
0
def assert_200(response):
    """Assert we get status code 200."""
    expect_status_in(response, (200, 201))
Ejemplo n.º 17
0
 def test_pass(self):
     response.status_code = 200
     expect.expect_status_in(response, {200, 201})
Ejemplo n.º 18
0
 def test_fail(self):
     response.status_code = 400
     with self.assertRaises(WooperAssertionError):
         expect.expect_status_in(response, {200, 401, 500})