Ejemplo n.º 1
0
def replay_event(request, team, project, group, event_id):
    try:
        event = Event.objects.get(group=group, id=event_id)
    except Event.DoesNotExist:
        return HttpResponseRedirect(reverse('sentry'))

    interfaces = event.interfaces
    if 'sentry.interfaces.Http' not in interfaces:
        # TODO: show a proper error
        return HttpResponseRedirect(reverse('sentry'))

    http = interfaces['sentry.interfaces.Http']
    if http.headers:
        headers = '\n'.join('%s: %s' % (k, v)
                            for k, v in http.headers.iteritems()
                            if k[0].upper() == k[0])
    else:
        headers = ''

    if isinstance(http.data, dict):
        data = safe_urlencode(http.data)
    else:
        data = http.data

    if http.query_string:
        full_url = http.url + '?' + http.query_string
    else:
        full_url = http.url

    initial = {
        'url': full_url,
        'method': http.method,
        'headers': headers,
        'data': data,
    }

    form = ReplayForm(request.POST or None, initial=initial)
    if form.is_valid():
        result = Replayer(
            url=form.cleaned_data['url'],
            method=form.cleaned_data['method'],
            data=form.cleaned_data['data'],
            headers=form.cleaned_data['headers'],
        ).replay()
    else:
        result = None

    context = {
        'team': team,
        'project': project,
        'group': event.group,
        'event': event,
        'form': form,
        'result': result,
    }
    context.update(csrf(request))

    return render_to_response('sentry/events/replay_request.html', context,
                              request)
Ejemplo n.º 2
0
def replay_event(request, team, project, group, event_id):
    try:
        event = Event.objects.get(group=group, id=event_id)
    except Event.DoesNotExist:
        return HttpResponseRedirect(reverse('sentry'))

    Event.objects.bind_nodes([event], 'data')

    interfaces = event.interfaces
    if 'sentry.interfaces.Http' not in interfaces:
        # TODO: show a proper error
        return HttpResponseRedirect(reverse('sentry'))

    http = interfaces['sentry.interfaces.Http']
    if http.headers:
        headers = '\n'.join('%s: %s' % (k, v) for k, v in http.headers.iteritems() if k[0].upper() == k[0])
    else:
        headers = ''

    if isinstance(http.data, dict):
        data = safe_urlencode(http.data)
    else:
        data = http.data

    if http.query_string:
        full_url = http.url + '?' + http.query_string
    else:
        full_url = http.url

    initial = {
        'url': full_url,
        'method': http.method,
        'headers': headers,
        'data': data,
    }

    form = ReplayForm(request.POST or None, initial=initial)
    if form.is_valid():
        result = Replayer(
            url=form.cleaned_data['url'],
            method=form.cleaned_data['method'],
            data=form.cleaned_data['data'],
            headers=form.cleaned_data['headers'],
        ).replay()
    else:
        result = None

    context = {
        'team': team,
        'project': project,
        'group': event.group,
        'event': event,
        'form': form,
        'result': result,
    }
    context.update(csrf(request))

    return render_to_response('sentry/events/replay_request.html', context, request)
Ejemplo n.º 3
0
 def test_it_works(self):
     form = ReplayForm(dict(
         url='http://example.com',
         method='GET',
         data='',
         headers='Foo: bar\nContent-Type: text/plain',
     ))
     assert form.is_valid()
     assert form.cleaned_data['headers'] == {'Foo': 'bar', 'Content-Type': 'text/plain'}
Ejemplo n.º 4
0
def replay_event(request, organization, project, group, event_id):
    try:
        event = Event.objects.get(group=group, id=event_id)
    except Event.DoesNotExist:
        return HttpResponseRedirect(reverse('sentry'))

    Event.objects.bind_nodes([event], 'data')

    interfaces = event.interfaces
    if 'sentry.interfaces.Http' not in interfaces:
        # TODO: show a proper error
        return HttpResponseRedirect(reverse('sentry'))

    # TODO(mattrobenolt): Add Cookie as a header
    http = interfaces['sentry.interfaces.Http']
    if http.headers:
        headers = '\n'.join('%s: %s' % (k, v) for k, v in http.headers
                            if k[0].upper() == k[0])
    else:
        headers = ''

    if isinstance(http.data, dict):
        data = safe_urlencode(http.data)
    else:
        data = http.data

    initial = {
        'url': urlparse.urldefrag(http.full_url)[0],
        'method': http.method,
        'headers': headers,
        'data': data,
    }

    form = ReplayForm(request.POST or None, initial=initial)
    if form.is_valid():
        result = Replayer(
            url=form.cleaned_data['url'],
            method=form.cleaned_data['method'],
            data=form.cleaned_data['data'],
            headers=form.cleaned_data['headers'],
        ).replay()
    else:
        result = None

    context = {
        'organization': organization,
        'team': project.team,
        'project': project,
        'group': event.group,
        'event': event,
        'form': form,
        'result': result,
    }
    context.update(csrf(request))

    return render_to_response('sentry/events/replay_request.html', context,
                              request)
Ejemplo n.º 5
0
 def test_it_works(self):
     form = ReplayForm(
         dict(
             url='http://example.com',
             method='GET',
             data='',
             headers='Foo: bar\nContent-Type: text/plain',
         ))
     assert form.is_valid()
     assert form.cleaned_data['headers'] == {
         'Foo': 'bar',
         'Content-Type': 'text/plain'
     }
Ejemplo n.º 6
0
    def handle(self, request, organization, project, team, group_id, event_id):
        try:
            event = Event.objects.get(group=group_id, id=event_id)
        except Event.DoesNotExist:
            return self.redirect(reverse('sentry'))

        Event.objects.bind_nodes([event], 'data')

        interfaces = event.interfaces
        if 'sentry.interfaces.Http' not in interfaces:
            # TODO: show a proper error
            return self.redirect(reverse('sentry'))

        # TODO(mattrobenolt): Add Cookie as a header
        http = interfaces['sentry.interfaces.Http']
        if http.headers:
            headers = '\n'.join('%s: %s' % (k, v) for k, v in http.headers if k[0].upper() == k[0])
        else:
            headers = ''

        if isinstance(http.data, dict):
            data = safe_urlencode(http.data)
        else:
            data = http.data

        initial = {
            'url': urlparse.urldefrag(http.full_url)[0],
            'method': http.method,
            'headers': headers,
            'data': data,
        }

        form = ReplayForm(request.POST or None, initial=initial)
        if form.is_valid():
            result = Replayer(
                url=form.cleaned_data['url'],
                method=form.cleaned_data['method'],
                data=form.cleaned_data['data'],
                headers=form.cleaned_data['headers'],
            ).replay()
        else:
            result = None

        context = {
            'group': event.group,
            'event': event,
            'form': form,
            'result': result,
        }

        return self.respond('sentry/events/replay_request.html', context)