#!perl
use Cassandane::Tiny;

sub test_blob_upload_too_large
    :min_version_3_9 :JMAPExtensions
{
    my $self = shift;
    my $jmap = $self->{jmap};

    xlog "Assert Problem Details report";
    my $httpReq = {
        headers => {
            'Authorization' => $jmap->auth_header(),
        },
        content => 'X' x 1025,
    };
    my $httpRes = $jmap->ua->post($jmap->uploaduri('cassandane'), $httpReq);
    if ($ENV{DEBUGJMAP}) {
        warn "JMAP " . Dumper($httpReq, $httpRes);
    }
    $self->assert_str_equals("413", $httpRes->{status});
    my $res = eval { decode_json($httpRes->{content}) };
    $self->assert_str_equals("413", $res->{status});
    $self->assert_str_equals("Content Too Large", $res->{title});
    $self->assert_str_equals("urn:ietf:params:jmap:error:limit", $res->{type});
    $self->assert_str_equals("maxSizeUpload", $res->{limit});
}
