test/case_and_dot_address_test.cc
author Krista Bennett <krista@pep-project.org>
Wed, 07 Feb 2018 16:16:40 +0100
branchENGINE-250
changeset 2482 c713df1942dd
parent 2481 dd1eaa8cc1eb
permissions -rw-r--r--
Probably own identity issues.
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@2482
    28
    char* user_id = get_new_uuid();
krista@1886
    29
    
krista@1886
    30
    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.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
    assert(statuspub == PEP_STATUS_OK);
krista@1886
    39
krista@2482
    40
    pEp_identity * alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", user_id, "Alice Test");
krista@2482
    41
krista@2308
    42
    status = trust_personal_key(session, alice_id);
krista@2482
    43
krista@2482
    44
    pEp_identity * new_alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", user_id, "Alice Test");
krista@2308
    45
    status = update_identity(session, new_alice_id);
krista@2308
    46
    assert(new_alice_id->fpr);
krista@2308
    47
    assert(strcmp(new_alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@2308
    48
    free_identity(new_alice_id);
krista@1886
    49
    free_identity(alice_id);
krista@1886
    50
    alice_id = NULL;
krista@2308
    51
    new_alice_id = NULL;
krista@1886
    52
krista@2482
    53
    alice_id = new_identity(alice_email_case, NULL, user_id, "Alice Test");
krista@2482
    54
    status = update_identity(session, alice_id);
krista@1886
    55
    assert(alice_id->fpr);
krista@2481
    56
    cout << "Alice email: " << alice_email_case << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
krista@1886
    57
    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@1886
    58
    free_identity(alice_id);
krista@1886
    59
    alice_id = NULL;
krista@1886
    60
krista@2482
    61
    alice_id = new_identity(alice_email_dot, NULL, user_id, "Alice Test");
krista@2482
    62
    status = update_identity(session, alice_id);
krista@1886
    63
    assert(alice_id->fpr);
krista@2481
    64
    cout << "Alice email: " << alice_email_dot << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
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@2482
    69
    alice_id = new_identity(alice_email_dotless, NULL, user_id, "Alice Test");
krista@2482
    70
    status = update_identity(session, alice_id);
krista@1886
    71
    assert(alice_id->fpr);
krista@2481
    72
    cout << "Alice email: " << alice_email_dotless << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
krista@1886
    73
    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@1886
    74
    free_identity(alice_id);
krista@1886
    75
    alice_id = NULL;
krista@1886
    76
krista@2482
    77
    alice_id = new_identity(alice_email_case_and_dot, NULL, user_id, "Alice Test");
krista@2482
    78
    status = update_identity(session, alice_id);
krista@1886
    79
    assert(alice_id->fpr);
krista@2481
    80
    cout << "Alice email: " << alice_email_case_and_dot << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
krista@1886
    81
    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@1886
    82
    free_identity(alice_id);
krista@1886
    83
    alice_id = NULL;
krista@1886
    84
    
krista@1886
    85
    release(session);
krista@1886
    86
krista@1886
    87
    return 0;
krista@1886
    88
}