test/src/engine_tests/EnterLeaveDeviceGroupTests.cc
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 01 Apr 2019 16:42:59 +0200
branchsync
changeset 3425 495866c118e7
parent 3422 09bec729847d
child 3436 bf27fae218c5
permissions -rw-r--r--
Test stuff, committing to move to other branch
krista@3422
     1
// This file is under GNU General Public License 3.0
krista@3422
     2
// see LICENSE.txt
krista@3422
     3
krista@3422
     4
#include <stdlib.h>
krista@3422
     5
#include <string>
krista@3422
     6
#include <cstring>
krista@3422
     7
krista@3422
     8
#include "pEpEngine.h"
krista@3422
     9
krista@3422
    10
#include "test_util.h"
krista@3422
    11
#include "sync_api.h"
krista@3422
    12
#include <cpptest.h>
krista@3422
    13
#include "EngineTestIndividualSuite.h"
krista@3422
    14
#include "EnterLeaveDeviceGroupTests.h"
krista@3422
    15
krista@3422
    16
using namespace std;
krista@3422
    17
krista@3422
    18
EnterLeaveDeviceGroupTests::EnterLeaveDeviceGroupTests(string suitename, string test_home_dir) :
krista@3422
    19
    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
krista@3422
    20
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_no_own"),
krista@3422
    21
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_no_own)));
krista@3422
    22
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_empty"),
krista@3422
    23
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_empty)));
krista@3422
    24
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_one"),
krista@3422
    25
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_one)));
krista@3422
    26
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_many"),
krista@3422
    27
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_many)));
krista@3422
    28
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_single_not_me"),
krista@3422
    29
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_single_not_me)));
krista@3422
    30
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_single_many_w_not_me"),
krista@3422
    31
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_single_many_w_not_me)));
krista@3422
    32
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_many_empty"),
krista@3422
    33
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_many_empty)));
krista@3422
    34
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_one"),
krista@3422
    35
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_one)));
krista@3422
    36
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many"),
krista@3422
    37
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many)));
krista@3422
    38
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many_w_not_me"),
krista@3422
    39
                                                                      static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many_w_not_me)));
krista@3422
    40
}
krista@3422
    41
krista@3422
    42
void EnterLeaveDeviceGroupTests::check_enter_device_group_no_own() {    
krista@3422
    43
    pEp_identity* alice_id = NULL;
krista@3425
    44
    TEST_ASSERT(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));
krista@3422
    45
    PEP_STATUS status = set_up_ident_from_scratch(session,
krista@3422
    46
                                "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
krista@3422
    47
                                "pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", 
krista@3422
    48
                                "ALICE", "Alice in Wonderland", &alice_id, false
krista@3422
    49
                        );
krista@3422
    50
                        
krista@3422
    51
    TEST_ASSERT(status == PEP_STATUS_OK);
krista@3422
    52
    status = enter_device_group(session, NULL);
krista@3422
    53
    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
krista@3422
    54
    
krista@3422
    55
    status = update_identity(session, alice_id);
krista@3422
    56
    TEST_ASSERT(!(alice_id->flags & PEP_idf_devicegroup));
krista@3422
    57
krista@3422
    58
    TEST_ASSERT(true);
krista@3422
    59
}
krista@3422
    60
krista@3422
    61
void EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_empty() {    
krista@3422
    62
    pEp_identity* alice_id = NULL;
krista@3425
    63
    TEST_ASSERT(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));    
krista@3422
    64
    PEP_STATUS status = set_up_ident_from_scratch(session,
krista@3422
    65
                                "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
krista@3422
    66
                                "pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", 
krista@3422
    67
                                "ALICE", "Alice in Wonderland", &alice_id, true
krista@3422
    68
                        );    
krista@3422
    69
krista@3422
    70
    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
krista@3422
    71
    status = myself(session, alice_id);
krista@3422
    72
krista@3422
    73
    TEST_ASSERT(alice_id->me);
krista@3422
    74
    TEST_ASSERT(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@3422
    75
    status = enter_device_group(session, NULL);
krista@3422
    76
    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
krista@3422
    77
    
krista@3422
    78
    status = myself(session, alice_id);
krista@3422
    79
    TEST_ASSERT(status == PEP_STATUS_OK);    
krista@3422
    80
    TEST_ASSERT_MSG(alice_id->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id->flags).c_str());
krista@3422
    81
                        
krista@3422
    82
    TEST_ASSERT(true);
krista@3422
    83
}
krista@3422
    84
krista@3422
    85
void EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_one() {    
krista@3425
    86
    pEp_identity* alice_id = NULL;
krista@3425
    87
    TEST_ASSERT(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));    
krista@3425
    88
    PEP_STATUS status = set_up_ident_from_scratch(session,
krista@3425
    89
                                "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
krista@3425
    90
                                "pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", 
krista@3425
    91
                                "ALICE", "Alice in Wonderland", &alice_id, true
krista@3425
    92
                        );    
krista@3425
    93
krista@3425
    94
    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
krista@3425
    95
    status = myself(session, alice_id);
krista@3425
    96
krista@3425
    97
    TEST_ASSERT(alice_id->me);
krista@3425
    98
    TEST_ASSERT(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
krista@3425
    99
    identity_list* ids_to_group = new_identity_list(alice_id);
krista@3425
   100
    status = enter_device_group(session, ids_to_group);
krista@3425
   101
    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
krista@3425
   102
    
krista@3425
   103
    status = myself(session, alice_id);
krista@3425
   104
    TEST_ASSERT(status == PEP_STATUS_OK);    
krista@3425
   105
    TEST_ASSERT_MSG(alice_id->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id->flags).c_str());
krista@3425
   106
                        
krista@3422
   107
    TEST_ASSERT(true);
krista@3422
   108
}
krista@3422
   109
krista@3422
   110
void EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_many() {    
krista@3422
   111
    TEST_ASSERT(true);
krista@3422
   112
}
krista@3422
   113
krista@3422
   114
void EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_single_not_me() {    
krista@3422
   115
    TEST_ASSERT(true);
krista@3422
   116
}
krista@3422
   117
krista@3422
   118
void EnterLeaveDeviceGroupTests::check_enter_device_group_one_own_single_many_w_not_me() {    
krista@3422
   119
    TEST_ASSERT(true);
krista@3422
   120
}
krista@3422
   121
krista@3422
   122
void EnterLeaveDeviceGroupTests::check_enter_device_group_many_empty() {    
krista@3422
   123
    TEST_ASSERT(true);
krista@3422
   124
}
krista@3422
   125
krista@3422
   126
void EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_one() {    
krista@3422
   127
    TEST_ASSERT(true);
krista@3422
   128
}
krista@3422
   129
krista@3422
   130
void EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many() {    
krista@3422
   131
    TEST_ASSERT(true);
krista@3422
   132
}
krista@3422
   133
krista@3422
   134
void EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many_w_not_me() {    
krista@3422
   135
    TEST_ASSERT(true);
krista@3422
   136
}