test/case_and_dot_address_test.cc
author Krista Bennett <krista@pep-project.org>
Fri, 19 Jan 2018 14:12:02 +0100
changeset 2418 05678e77bc6a
parent 2308 b7ef1c9005ae
child 2481 dd1eaa8cc1eb
permissions -rw-r--r--
fixed update_identity call that could be called on a myself value in outgoing_message_rating
krista@1886
     1
// This file is under GNU General Public License 3.0
krista@1886
     2
// see LICENSE.txt
krista@1886
     3
krista@1886
     4
#include <stdlib.h>
krista@1886
     5
#include <string.h>
krista@1886
     6
#include <time.h>
krista@1886
     7
#include "platform.h"
krista@1886
     8
#include <iostream>
krista@1886
     9
#include <fstream>
krista@1886
    10
#include <assert.h>
krista@1886
    11
#include "mime.h"
krista@1886
    12
#include "message_api.h"
krista@1886
    13
#include "test_util.h"
krista@1886
    14
krista@1886
    15
using namespace std;
krista@1886
    16
krista@1886
    17
int main() {
krista@1886
    18
    cout << "\n*** case_and_dot_address_test.cc ***\n\n";
krista@1886
    19
krista@1886
    20
    PEP_SESSION session;
krista@1886
    21
    
krista@1886
    22
    cout << "calling init()\n";
krista@1886
    23
    PEP_STATUS status = init(&session);   
krista@1886
    24
    assert(status == PEP_STATUS_OK);
krista@1886
    25
    assert(session);
krista@1886
    26
    cout << "init() completed.\n";
krista@1886
    27
    
krista@1886
    28
    
krista@1886
    29
    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
krista@1886
    30
    const string alice_priv_key = slurp("test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
krista@1886
    31
krista@1886
    32
    const char* alice_email_case = "pEp.teST.AlICe@pEP-pRoJeCt.ORG";
krista@1886
    33
    const char* alice_email_dot = "pe.p.te.st.a.l.i.ce@pep-project.org";
krista@1886
    34
    const char* alice_email_dotless = "peptestalice@pep-project.org";
krista@1886
    35
    const char* alice_email_case_and_dot = "PE.p.teS.t.ALICE@pep-project.OrG";
krista@1886
    36
krista@1886
    37
    PEP_STATUS statuspub = import_key(session, alice_pub_key.c_str(), alice_pub_key.length(), NULL);
krista@1886
    38
    PEP_STATUS statuspriv = import_key(session, alice_priv_key.c_str(), alice_priv_key.length(), NULL);
krista@1886
    39
    assert(statuspub == PEP_STATUS_OK);
krista@1886
    40
    assert(statuspriv == PEP_STATUS_OK);
krista@1886
    41
krista@2308
    42
    pEp_identity * alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
krista@2308
    43
    identity_list* own_id = new_identity_list(alice_id);
krista@2308
    44
    status = initialise_own_identities(session, own_id);
krista@2308
    45
    status = trust_personal_key(session, alice_id);
krista@2308
    46
    pEp_identity * new_alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
krista@2308
    47
    status = update_identity(session, new_alice_id);
krista@2308
    48
    assert(new_alice_id->fpr);
krista@2308
    49
    assert(strcmp(new_alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@2308
    50
    free_identity(new_alice_id);
krista@1886
    51
    free_identity(alice_id);
krista@1886
    52
    alice_id = NULL;
krista@2308
    53
    new_alice_id = NULL;
krista@1886
    54
krista@1886
    55
    alice_id = new_identity(alice_email_case, NULL, PEP_OWN_USERID, "Alice Test");
krista@2308
    56
    status = myself(session, alice_id);
krista@1886
    57
    assert(alice_id->fpr);
krista@1886
    58
    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@1886
    59
    free_identity(alice_id);
krista@1886
    60
    alice_id = NULL;
krista@1886
    61
krista@1886
    62
    alice_id = new_identity(alice_email_dot, NULL, PEP_OWN_USERID, "Alice Test");
krista@2308
    63
    status = myself(session, alice_id);
krista@1886
    64
    assert(alice_id->fpr);
krista@1886
    65
    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@1886
    66
    free_identity(alice_id);
krista@1886
    67
    alice_id = NULL;
krista@1886
    68
krista@1886
    69
    alice_id = new_identity(alice_email_dotless, NULL, PEP_OWN_USERID, "Alice Test");
krista@2308
    70
    status = myself(session, alice_id);
krista@1886
    71
    assert(alice_id->fpr);
krista@1886
    72
    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@1886
    73
    free_identity(alice_id);
krista@1886
    74
    alice_id = NULL;
krista@1886
    75
krista@1886
    76
    alice_id = new_identity(alice_email_case_and_dot, NULL, PEP_OWN_USERID, "Alice Test");
krista@2308
    77
    status = myself(session, alice_id);
krista@1886
    78
    assert(alice_id->fpr);
krista@1886
    79
    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@1886
    80
    free_identity(alice_id);
krista@1886
    81
    alice_id = NULL;
krista@1886
    82
    
krista@1886
    83
    release(session);
krista@1886
    84
krista@1886
    85
    return 0;
krista@1886
    86
}