Skip to content

Commit

Permalink
jmap_contact.c: Add Card[Group]/get methods (with a simple test)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksmurchison committed Apr 24, 2023
1 parent 3d2cf33 commit e0990d5
Show file tree
Hide file tree
Showing 2 changed files with 1,420 additions and 2 deletions.
53 changes: 53 additions & 0 deletions cassandane/tiny-tests/JMAPContacts/card-get-apple-countrycode
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!perl
use Cassandane::Tiny;

sub test_card_get_apple_countrycode
:min_version_3_9 :needs_component_jmap
{
my ($self) = @_;
my $jmap = $self->{jmap};

my $service = $self->{instance}->get_service("http");
$ENV{DEBUGDAV} = 1;
my $carddav = Net::CardDAVTalk->new(
user => 'cassandane',
password => 'pass',
host => $service->host(),
port => $service->port(),
scheme => 'http',
url => '/',
expandurl => 1,
);

my $id = 'ae2640cc-234a-4dd9-95cc-3106258445b9';
my $href = "Default/$id.vcf";
my $card = <<EOF;
BEGIN:VCARD
VERSION:3.0
UID:$id
N:Gump;Forrest;;Mr.
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
REV:2008-04-24T19:52:43Z
item1.ADR;prop-id=A1;type=WORK:;;2 Example Avenue;Anytown;NY;01111;USA
item1.X-ABADR:US
item1.X-ABLabel:xyz
item2.ADR;prop-id=A2;type=WORK:;;Beispielstrasse 2;IrgendwoStadt;IrgendwoLand;00000;Germany
item2.X-ABADR:de
END:VCARD
EOF

$card =~ s/\r?\n/\r\n/gs;
$carddav->Request('PUT', $href, $card, 'Content-Type' => 'text/vcard');

my $res = $jmap->CallMethods([
['Card/get', {
properties => ['addresses']
}, 'R1']
]);

$self->assert_str_equals('us', $res->[0][1]{list}[0]{addresses}{A1}{countryCode});
$self->assert_str_equals('xyz', $res->[0][1]{list}[0]{addresses}{A1}{label});
$self->assert_str_equals('de', $res->[0][1]{list}[0]{addresses}{A2}{countryCode});
}
Loading

0 comments on commit e0990d5

Please sign in to comment.