more testing. seems to work. sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 06 Feb 2020 09:45:47 +0100
branchsync
changeset 441167187599f606
parent 4410 a1121e886baa
child 4413 147e3e145785
more testing. seems to work.
test/src/KeyResetMessageTest.cc
     1.1 --- a/test/src/KeyResetMessageTest.cc	Wed Feb 05 19:55:56 2020 +0100
     1.2 +++ b/test/src/KeyResetMessageTest.cc	Thu Feb 06 09:45:47 2020 +0100
     1.3 @@ -629,6 +629,10 @@
     1.4      ASSERT_TRUE(alice->fpr && alice->fpr[0]);
     1.5      ASSERT_TRUE(alice->me);
     1.6      ASSERT_STREQ(alice->fpr, alice_fpr);
     1.7 +    
     1.8 +    char* main_key = NULL;
     1.9 +    status = get_main_user_fpr(session, alice->user_id, &main_key);
    1.10 +    ASSERT_STREQ(main_key, alice_fpr);        
    1.11  
    1.12      status = set_identity_flags(session, alice, alice->flags | PEP_idf_devicegroup);
    1.13      status = key_reset_identity(session, alice, alice_fpr);
    1.14 @@ -638,6 +642,11 @@
    1.15      ASSERT_TRUE(alice_new_fpr && alice_new_fpr[0]);
    1.16      ASSERT_STRNE(alice_fpr, alice_new_fpr);
    1.17  
    1.18 +    main_key = NULL;
    1.19 +    status = get_main_user_fpr(session, alice->user_id, &main_key);
    1.20 +    ASSERT_STRNE(main_key, alice_fpr);
    1.21 +
    1.22 +
    1.23      ASSERT_EQ(m_queue.size(), 1);
    1.24  
    1.25      if (false) {
    1.26 @@ -683,6 +692,10 @@
    1.27      ASSERT_TRUE(alice->fpr && alice->fpr[0]);
    1.28      ASSERT_TRUE(alice->me);
    1.29      ASSERT_STREQ(alice->fpr, alice_fpr);
    1.30 +    
    1.31 +    char* main_key = NULL;
    1.32 +    status = get_main_user_fpr(session, alice->user_id, &main_key);
    1.33 +    ASSERT_STREQ(main_key, alice_fpr);    
    1.34  
    1.35      status = set_identity_flags(session, alice, alice->flags | PEP_idf_devicegroup);
    1.36      ASSERT_EQ(status , PEP_STATUS_OK);
    1.37 @@ -707,6 +720,10 @@
    1.38      ASSERT_EQ(status, PEP_STATUS_OK);
    1.39      ASSERT_TRUE(revoked);
    1.40  
    1.41 +    main_key = NULL;
    1.42 +    status = get_main_user_fpr(session, alice->user_id, &main_key);
    1.43 +    ASSERT_STRNE(main_key, alice_fpr);
    1.44 +    ASSERT_STREQ(main_key, "0D9374B9573548600272BF1D84A892F08ED7BBBF");    
    1.45  }
    1.46  
    1.47  TEST_F(KeyResetMessageTest, check_reset_grouped_own_multi_ident_one_fpr) {
    1.48 @@ -1217,6 +1234,11 @@
    1.49      ASSERT_EQ(status, PEP_STATUS_OK);
    1.50      ASSERT_STREQ(pubkey3, alex_id3->fpr);
    1.51  
    1.52 +    char* old_main_key = NULL;
    1.53 +    status = get_main_user_fpr(session, "AlexID", &old_main_key);
    1.54 +    ASSERT_NE(old_main_key, nullptr);
    1.55 +
    1.56 +
    1.57      const int num_msgs = 2;
    1.58      for (int i = 0; i < num_msgs; i++) {
    1.59          // receive reset messages
    1.60 @@ -1236,6 +1258,10 @@
    1.61          ASSERT_EQ(status, PEP_STATUS_OK);        
    1.62      }
    1.63  
    1.64 +    char* new_main_key = NULL;
    1.65 +    status = get_main_user_fpr(session, "AlexID", &new_main_key);
    1.66 +    ASSERT_STRNE(old_main_key, new_main_key);
    1.67 +
    1.68      status = myself(session, alex_id);
    1.69      ASSERT_EQ(status, PEP_STATUS_OK);
    1.70      ASSERT_STREQ(replkey1, alex_id->fpr);
    1.71 @@ -1580,8 +1606,19 @@
    1.72      ASSERT_EQ(status , PEP_STATUS_OK);
    1.73      ASSERT_EQ(bob->comm_type , PEP_ct_pEp);
    1.74  
    1.75 +    char* main_key = NULL;
    1.76 +    status = get_main_user_fpr(session, bob->user_id, &main_key);
    1.77 +    ASSERT_STREQ(main_key, bob->fpr);
    1.78 +
    1.79 +    
    1.80      // Ok, let's reset it
    1.81      status = key_reset_identity(session, bob, bob->fpr);
    1.82 +    
    1.83 +    main_key = NULL;
    1.84 +    status = get_main_user_fpr(session, bob->user_id, &main_key);
    1.85 +    ASSERT_EQ(status, PEP_KEY_NOT_FOUND);
    1.86 +    ASSERT_STREQ(main_key, nullptr);
    1.87 +    
    1.88      status = update_identity(session, bob);
    1.89      ASSERT_EQ(status , PEP_STATUS_OK);
    1.90      ASSERT_EQ(bob->comm_type , PEP_ct_key_not_found);
    1.91 @@ -2120,6 +2157,52 @@
    1.92      free_identity(alex_id);
    1.93  }
    1.94  
    1.95 +TEST_F(KeyResetMessageTest, check_reset_replace_user_fpr_own_direct_reset) {
    1.96 +    char* pubkey3 = strdup("3C1E713D8519D7F907E3142D179EAA24A216E95A");
    1.97 +    char* pubkey4 = strdup("B4CE2F6947B6947C500F0687AEFDE530BDA17020");
    1.98 +
    1.99 +    pEp_identity* alex_id = new_identity("pep.test.alexander@darthmama.org",
   1.100 +                                         NULL,
   1.101 +                                         "AlexID",
   1.102 +                                         "Alexander Braithwaite");
   1.103 +
   1.104 +    pEp_identity* alex_id2 = new_identity("pep.test.alexander6@darthmama.org",
   1.105 +                                          NULL,
   1.106 +                                          "AlexID",
   1.107 +                                          "Alexander Braithwaite");
   1.108 +
   1.109 +
   1.110 +    PEP_STATUS status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
   1.111 +    status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc");
   1.112 +    status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0xA216E95A_priv.asc");
   1.113 +    status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0xBDA17020_priv.asc");
   1.114 +
   1.115 +    alex_id->me = true;
   1.116 +    status = set_own_key(session, alex_id, pubkey3);
   1.117 +    status = myself(session, alex_id);
   1.118 +
   1.119 +    char* main_key = NULL;
   1.120 +    
   1.121 +    status = get_main_user_fpr(session, alex_id->user_id, &main_key);
   1.122 +    ASSERT_NE(main_key, nullptr);
   1.123 +    ASSERT_STREQ(main_key, pubkey3);
   1.124 +    
   1.125 +    alex_id2->me = true;
   1.126 +    status = set_own_key(session, alex_id2, pubkey4);
   1.127 +    status = myself(session, alex_id2);
   1.128 +
   1.129 +    status = key_reset_all_own_keys(session);
   1.130 +
   1.131 +    stringlist_t* keylist = NULL;
   1.132 +
   1.133 +    status = get_main_user_fpr(session, alex_id->user_id, &main_key);
   1.134 +    ASSERT_NE(main_key, nullptr);
   1.135 +    ASSERT_STRNE(main_key, pubkey3);
   1.136 +
   1.137 +    free(pubkey3);
   1.138 +    free(pubkey4);
   1.139 +    free_identity(alex_id);
   1.140 +}
   1.141  
   1.142  TEST_F(KeyResetMessageTest, check_reset_all_own_no_own) {
   1.143        char* pubkey1 = strdup("74D79B4496E289BD8A71B70BA8E2C4530019697D");