tests ENGINE-559
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 26 Jun 2019 16:43:06 +0200
branchENGINE-559
changeset 3881b63cd0206453
parent 3880 1642cd731c9f
child 3882 15ded0400e8b
tests
test/include/Message2_1Tests.h
test/include/test_util.h
test/src/SuiteMaker.cc
test/src/engine_tests/Message2_1Tests.cc
test/src/util/test_util.cc
     1.1 --- a/test/include/Message2_1Tests.h	Wed Jun 26 11:36:48 2019 +0200
     1.2 +++ b/test/include/Message2_1Tests.h	Wed Jun 26 16:43:06 2019 +0200
     1.3 @@ -13,7 +13,16 @@
     1.4      public:
     1.5          Message2_1Tests(string test_suite, string test_home_dir);
     1.6      private:
     1.7 -        void check_message2_1();
     1.8 +        bool verify_message_version_produced(message* enc_msg, unsigned int* maj_inout, unsigned int* min_inout);
     1.9 +        
    1.10 +        void check_message2_1_recip_2_0();
    1.11 +        void check_message2_1_recip_OpenPGP();
    1.12 +        void check_message2_1_recip_2_1();
    1.13 +        void check_message2_1_recip_1_0_from_msg_OpenPGP();
    1.14 +        void check_message2_1_recip_2_0_from_msg();
    1.15 +        void check_message2_1_recip_2_1_from_msg();
    1.16 +        void check_message2_1_recip_mixed_2_0();
    1.17 +        void check_message2_1_recip_mixed_1_0_OpenPGP();
    1.18  };
    1.19  
    1.20  #endif
     2.1 --- a/test/include/test_util.h	Wed Jun 26 11:36:48 2019 +0200
     2.2 +++ b/test/include/test_util.h	Wed Jun 26 16:43:06 2019 +0200
     2.3 @@ -42,6 +42,16 @@
     2.4      BERND
     2.5  } pEp_test_ident_preset;
     2.6  
     2.7 +PEP_STATUS set_up_preset(PEP_SESSION session,
     2.8 +                         pEp_test_ident_preset preset_name,
     2.9 +                         bool set_identity, 
    2.10 +                         bool set_pep,
    2.11 +                         bool trust,
    2.12 +                         bool set_own, 
    2.13 +                         bool setup_private, 
    2.14 +                         pEp_identity** ident);
    2.15 +
    2.16 +
    2.17  PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname);
    2.18  PEP_STATUS set_up_ident_from_scratch(PEP_SESSION session, 
    2.19                                       const char* key_fname,
     3.1 --- a/test/src/SuiteMaker.cc	Wed Jun 26 11:36:48 2019 +0200
     3.2 +++ b/test/src/SuiteMaker.cc	Wed Jun 26 16:43:06 2019 +0200
     3.3 @@ -19,12 +19,12 @@
     3.4  #include "VerifyTests.h"
     3.5  #include "UserIdCollisionTests.h"
     3.6  #include "Engine463Tests.h"
     3.7 -#include "IOS1664Tests.h"
     3.8  #include "BloblistTests.h"
     3.9  #include "NewUpdateIdAndMyselfTests.h"
    3.10  #include "NoOwnIdentWritesOnDecryptTests.h"
    3.11  #include "LiteralFilenameTests.h"
    3.12  #include "I18nTests.h"
    3.13 +#include "Message2_1Tests.h"
    3.14  #include "IdentityListTests.h"
    3.15  #include "PgpBinaryTests.h"
    3.16  #include "SubkeyRatingEvalTests.h"
    3.17 @@ -85,12 +85,12 @@
    3.18      "VerifyTests",
    3.19      "UserIdCollisionTests",
    3.20      "Engine463Tests",
    3.21 -    "IOS1664Tests",
    3.22      "BloblistTests",
    3.23      "NewUpdateIdAndMyselfTests",
    3.24      "NoOwnIdentWritesOnDecryptTests",
    3.25      "LiteralFilenameTests",
    3.26      "I18nTests",
    3.27 +    "Message2_1Tests",
    3.28      "IdentityListTests",
    3.29      "PgpBinaryTests",
    3.30      "SubkeyRatingEvalTests",
    3.31 @@ -161,8 +161,6 @@
    3.32          *test_suite = new UserIdCollisionTests(test_class_name, test_home);
    3.33      else if (strcmp(test_class_name, "Engine463Tests") == 0)
    3.34          *test_suite = new Engine463Tests(test_class_name, test_home);
    3.35 -    else if (strcmp(test_class_name, "IOS1664Tests") == 0)
    3.36 -        *test_suite = new IOS1664Tests(test_class_name, test_home);
    3.37      else if (strcmp(test_class_name, "BloblistTests") == 0)
    3.38          *test_suite = new BloblistTests(test_class_name, test_home);
    3.39      else if (strcmp(test_class_name, "NewUpdateIdAndMyselfTests") == 0)
    3.40 @@ -173,6 +171,8 @@
    3.41          *test_suite = new LiteralFilenameTests(test_class_name, test_home);
    3.42      else if (strcmp(test_class_name, "I18nTests") == 0)
    3.43          *test_suite = new I18nTests(test_class_name, test_home);
    3.44 +    else if (strcmp(test_class_name, "Message2_1Tests") == 0)
    3.45 +        *test_suite = new Message2_1Tests(test_class_name, test_home);
    3.46      else if (strcmp(test_class_name, "IdentityListTests") == 0)
    3.47          *test_suite = new IdentityListTests(test_class_name, test_home);
    3.48      else if (strcmp(test_class_name, "PgpBinaryTests") == 0)
     4.1 --- a/test/src/engine_tests/Message2_1Tests.cc	Wed Jun 26 11:36:48 2019 +0200
     4.2 +++ b/test/src/engine_tests/Message2_1Tests.cc	Wed Jun 26 16:43:06 2019 +0200
     4.3 @@ -17,11 +17,25 @@
     4.4  
     4.5  Message2_1Tests::Message2_1Tests(string suitename, string test_home_dir) :
     4.6      EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
     4.7 -    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1"),
     4.8 -                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1)));
     4.9 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1_recip_2_0"),
    4.10 +                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1_recip_2_0)));
    4.11 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1_recip_OpenPGP"),
    4.12 +                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1_recip_OpenPGP)));
    4.13 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1_recip_2_1"),
    4.14 +                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1_recip_2_1)));
    4.15 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1_recip_1_0_from_msg_OpenPGP"),
    4.16 +                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1_recip_1_0_from_msg_OpenPGP)));
    4.17 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1_recip_2_0_from_msg"),
    4.18 +                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1_recip_2_0_from_msg)));
    4.19 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1_recip_2_1_from_msg"),
    4.20 +                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1_recip_2_1_from_msg)));
    4.21 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1_recip_mixed_2_0"),
    4.22 +                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1_recip_mixed_2_0)));
    4.23 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Message2_1Tests::check_message2_1_recip_mixed_1_0_OpenPGP"),
    4.24 +                                                                      static_cast<Func>(&Message2_1Tests::check_message2_1_recip_mixed_1_0_OpenPGP)));
    4.25  }
    4.26  
    4.27 -static bool verify_message_version_produced(message* enc_msg, unsigned int* maj_inout, unsigned it* min_inout) {
    4.28 +bool Message2_1Tests::verify_message_version_produced(message* enc_msg, unsigned int* maj_inout, unsigned int* min_inout) {
    4.29      if (!maj_inout || !min_inout)
    4.30          return false;
    4.31      int major = *maj_inout;
    4.32 @@ -31,10 +45,10 @@
    4.33      size_t psize = 0;
    4.34      stringlist_t* keylist = NULL;
    4.35      
    4.36 -    PEP_STATUS status = cryptotech[crypto].decrypt_and_verify(session, enc_msg->attachments->next->value,
    4.37 -                                                              enc_msg->attachments->next->size, NULL, 0,
    4.38 -                                                              &ptext, &psize, &_keylist,
    4.39 -                                                              NULL);
    4.40 +    PEP_STATUS status = decrypt_and_verify(session, enc_msg->attachments->next->value,
    4.41 +                                           enc_msg->attachments->next->size, NULL, 0,
    4.42 +                                           &ptext, &psize, &keylist,
    4.43 +                                           NULL);
    4.44  
    4.45      // fixme, check status
    4.46      if (strstr(ptext, "pEp-Wrapped-Message-Info: OUTER") != NULL && strstr(ptext, "pEp-Wrapped-Message-Info: OUTER") != NULL) {
    4.47 @@ -68,29 +82,65 @@
    4.48      }
    4.49  }
    4.50  
    4.51 +/* PEP_STATUS set_up_preset(PEP_SESSION session,
    4.52 +                         pEp_test_ident_preset preset_name,
    4.53 +                         bool set_ident, 
    4.54 +                         bool set_pep,
    4.55 +                         bool trust,
    4.56 +                         bool set_own, 
    4.57 +                         bool setup_private, 
    4.58 +                         pEp_identity** ident) {
    4.59 +*/
    4.60  void Message2_1Tests::check_message2_1_recip_2_0() {
    4.61 -    TEST_ASSERT(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));
    4.62 -    TEST_ASSERT(slurp_and_import_key(session, "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc"));    
    4.63 +
    4.64 +    pEp_identity* alice = NULL;
    4.65 +    pEp_identity* carol = NULL;
    4.66 +    
    4.67 +    PEP_STATUS status = set_up_preset(session, ALICE, 
    4.68 +                                      true, true, true, true, true, &alice);
    4.69 +
    4.70 +    TEST_ASSERT(status == PEP_STATUS_OK);
    4.71 +    TEST_ASSERT(alice);
    4.72 +    
    4.73 +    status = set_up_preset(session, CAROL, 
    4.74 +                           false, true, false, false, false, &carol);
    4.75 +
    4.76 +    TEST_ASSERT(status == PEP_STATUS_OK);
    4.77 +    TEST_ASSERT(carol);
    4.78  
    4.79      // default should be 2.0 after setting pep status
    4.80 +    status = update_identity(session, carol);
    4.81 +    TEST_ASSERT(status == PEP_STATUS_OK);
    4.82 +    TEST_ASSERT(carol->major_ver == 2);
    4.83 +    TEST_ASSERT(carol->minor_ver == 0);
    4.84 +    // generate message
    4.85 +    pEp_identity* carol_to = new_identity(carol->address, NULL, NULL, NULL);
    4.86      
    4.87 -    // generate message
    4.88 +    message* msg = new_message(PEP_dir_outgoing);
    4.89 +    
    4.90 +    msg->from = alice;
    4.91 +    msg->to = new_identity_list(carol_to);
    4.92 +    msg->shortmsg = strdup("Boom shaka laka");
    4.93 +    msg->longmsg = strdup("Don't you get sick of these?");
    4.94 +    
    4.95 +    message* enc_msg = NULL;
    4.96 +
    4.97 +    status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
    4.98 +    TEST_ASSERT(status == PEP_STATUS_OK);
    4.99      
   4.100      // ensure sent message is in 2.0 format
   4.101 +    unsigned int major = 2;
   4.102 +    unsigned int minor = 0;
   4.103 +    TEST_ASSERT_MSG(verify_message_version_produced(enc_msg, &major, &minor),
   4.104 +                                                    (to_string(major) + to_string(minor)).c_str());
   4.105 +    
   4.106 +    free_identity(carol);
   4.107 +    free_message(msg);
   4.108 +    free_message(enc_msg);
   4.109      TEST_ASSERT(true);
   4.110  }
   4.111  
   4.112 -void Message2_1Tests::check_message2_1_recip_1_0() {
   4.113 -    // set recip to 1.0
   4.114 -    
   4.115 -    // generate message
   4.116 -    
   4.117 -    // ensure sent message is in 1.0 format
   4.118 -    
   4.119 -    TEST_ASSERT(true);
   4.120 -}
   4.121 -
   4.122 -void Message2_1Tests::check_message2_1_recip_1_0_OpenPGP() {
   4.123 +void Message2_1Tests::check_message2_1_recip_OpenPGP() {
   4.124      // set recip to 1.0
   4.125      
   4.126      // generate message
   4.127 @@ -111,16 +161,6 @@
   4.128      TEST_ASSERT(true);
   4.129  }
   4.130  
   4.131 -void Message2_1Tests::check_message2_1_recip_1_0_from_msg() {
   4.132 -    // receive 1.0 message
   4.133 -
   4.134 -    // generate message
   4.135 -    
   4.136 -    // ensure sent message is in 1.0 format
   4.137 -
   4.138 -    TEST_ASSERT(true);
   4.139 -}
   4.140 -
   4.141  void Message2_1Tests::check_message2_1_recip_1_0_from_msg_OpenPGP() {
   4.142      // receive 1.0 message from OpenPGP
   4.143  
   4.144 @@ -156,16 +196,6 @@
   4.145      TEST_ASSERT(true);
   4.146  }
   4.147  
   4.148 -void Message2_1Tests::check_message2_1_recip_mixed_1_0() {
   4.149 -    // Set mixed recipient values
   4.150 -
   4.151 -    // generate message
   4.152 -    
   4.153 -    // ensure sent message is in 1.0 format
   4.154 -
   4.155 -    TEST_ASSERT(true);
   4.156 -}
   4.157 -
   4.158  void Message2_1Tests::check_message2_1_recip_mixed_1_0_OpenPGP() {
   4.159      // Set mixed recipient values
   4.160  
     5.1 --- a/test/src/util/test_util.cc	Wed Jun 26 11:36:48 2019 +0200
     5.2 +++ b/test/src/util/test_util.cc	Wed Jun 26 16:43:06 2019 +0200
     5.3 @@ -6,6 +6,7 @@
     5.4  #include "TestConstants.h"
     5.5  #include "mime.h"
     5.6  #include "message_api.h"
     5.7 +#include "keymanagement.h"
     5.8  
     5.9  #include <fstream>
    5.10  #include <sstream>
    5.11 @@ -17,6 +18,8 @@
    5.12  #include <unistd.h>
    5.13  #include <ftw.h>
    5.14  
    5.15 +using namespace std;
    5.16 +
    5.17  PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname) {
    5.18      const std::string key = slurp(fname);
    5.19      PEP_STATUS status = (key.empty() ? PEP_KEY_NOT_FOUND : PEP_STATUS_OK);
    5.20 @@ -692,14 +695,15 @@
    5.21      return status;
    5.22  }
    5.23  
    5.24 -PEP_STATUS set_up_preset(pEp_test_ident_preset preset_name,
    5.25 -                         bool set_identity, 
    5.26 +PEP_STATUS set_up_preset(PEP_SESSION session,
    5.27 +                         pEp_test_ident_preset preset_name,
    5.28 +                         bool set_ident, 
    5.29                           bool set_pep,
    5.30                           bool trust,
    5.31                           bool set_own, 
    5.32 -                         bool private, 
    5.33 +                         bool setup_private, 
    5.34                           pEp_identity** ident) {
    5.35 -    if (set_own && !set_identity)
    5.36 +    if (set_own && !set_ident)
    5.37          return PEP_ILLEGAL_VALUE;
    5.38          
    5.39      const char* name = NULL;
    5.40 @@ -708,6 +712,9 @@
    5.41      const char* key_prefix = NULL;
    5.42      string pubkey_dir = "test_keys/pub/";
    5.43      string privkey_dir = "test_keys/priv";
    5.44 +    const char* fpr = NULL;
    5.45 +    PEP_STATUS status = PEP_STATUS_OK;
    5.46 +    
    5.47      if (ident)
    5.48          *ident = NULL;
    5.49  
    5.50 @@ -719,150 +726,175 @@
    5.51              user_id = "ALICE";
    5.52              email = "pep.test.alice@pep-project.org";
    5.53              key_prefix = "pep-test-alice-0x6FF00E97";
    5.54 +            fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
    5.55              break;
    5.56          case APPLE:
    5.57              name = "Apple of my Computer";
    5.58              user_id = "APPLE";
    5.59              email = "pep.test.apple@pep-project.org";
    5.60              key_prefix = "pep-test-apple-0x1CCBC7D7";
    5.61 +            fpr = "3D8D9423D03DDF61B60161150313D94A1CCBC7D7";
    5.62              break;
    5.63          case BOB:
    5.64              name = "Bob Dog";
    5.65              user_id = "BOB";
    5.66              email = "pep.test.bob@pep-project.org";
    5.67              key_prefix = "pep-test-bob-0xC9C2EE39";
    5.68 +            fpr = "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39";
    5.69              break;
    5.70          case CAROL:
    5.71              name = "Carol Burnett";
    5.72              user_id = "CAROL";
    5.73              email = "pep-test-carol@pep-project.org";
    5.74              key_prefix = "pep-test-carol-0x42A85A42";
    5.75 +            fpr = "8DD4F5827B45839E9ACCA94687BDDFFB42A85A42";
    5.76              break;
    5.77          case DAVE:
    5.78 -            name = "Dave Brown";
    5.79 +            name = "The Hoff";
    5.80              user_id = "DAVE";
    5.81              email = "pep-test-dave@pep-project.org";
    5.82              key_prefix = "pep-test-dave-0xBB5BCCF6";
    5.83 +            fpr = "E8AC9779A2D13A15D8D55C84B049F489BB5BCCF6";
    5.84              break;
    5.85          case ERIN:
    5.86              name = "Erin Ireland";
    5.87              user_id = "ERIN";
    5.88              email = "pep-test-erin@pep-project.org";
    5.89              key_prefix = "pep-test-erin-0x9F8D7CBA";
    5.90 +            fpr = "1B0E197E8AE66277B8A024B9AEA69F509F8D7CBA";
    5.91              break;
    5.92          case FRANK:
    5.93              name = "Frank N. Furter";
    5.94              user_id = "FRANK";
    5.95              email = "pep-test-frank@pep-project.org";
    5.96              key_prefix = "pep-test-frank-0x9A7FC670";
    5.97 +            fpr = "B022B74476D8A8E1F01E55FBAB6972569A7FC670"; // currently expired
    5.98              break;
    5.99          case GABRIELLE:
   5.100              name = "Gabrielle Gonzales";
   5.101              user_id = "GABI";
   5.102              email = "pep-test-gabrielle@pep-project.org";
   5.103              key_prefix = "pep-test-gabrielle-0xE203586C";
   5.104 +            fpr = "906C9B8349954E82C5623C3C8C541BD4E203586C";
   5.105              break;
   5.106          case JOHN:
   5.107              name = "John Denver";
   5.108              user_id = "JOHN";
   5.109              email = "pep.test.john@pep-project.org";
   5.110              key_prefix = "pep-test-john-0x70DCF575";
   5.111 +            fpr = "AA2E4BEB93E5FE33DEFD8BE1135CD6D170DCF575";
   5.112              break;
   5.113          case ALEX:
   5.114              name = "Alex Braithwaite";
   5.115              user_id = "ALEX";
   5.116              email = "pep.test.alexander@peptest.ch";
   5.117              key_prefix = "pep.test.alexander-0x26B54E4E";
   5.118 +            fpr = "3AD9F60FAEB22675DB873A1362D6981326B54E4E";
   5.119              break;
   5.120          case ALEX_0:
   5.121 -            name = "ALEX";
   5.122 -            user_id = "pep.test.alexander0-0x3B7302DB";
   5.123 +            name = "Alex Braithwaite";
   5.124 +            user_id = "ALEX";
   5.125              email = "pep.test.alexander0@darthmama.org";
   5.126 -            key_prefix = "";
   5.127 +            key_prefix = "pep.test.alexander0-0x3B7302DB";
   5.128 +            fpr = "F4598A17D4690EB3B5B0F6A344F04E963B7302DB";
   5.129              break;
   5.130          case ALEX_1:
   5.131              name = "Alex Braithwaite";
   5.132              user_id = "ALEX";
   5.133              email = "pep.test.alexander1@darthmama.org";
   5.134              key_prefix = "pep.test.alexander1-0x541260F6";
   5.135 +            fpr = "59AF4C51492283522F6904531C09730A541260F6";
   5.136              break;
   5.137          case ALEX_2:
   5.138              name = "Alex Braithwaite";
   5.139              user_id = "ALEX";
   5.140              email = "pep.test.alexander2@darthmama.org";
   5.141              key_prefix = "pep.test.alexander2-0xA6512F30";
   5.142 +            fpr = "46A994F19077C05610870273C4B8AB0BA6512F30";
   5.143              break;
   5.144          case ALEX_3:
   5.145              name = "Alex Braithwaite";
   5.146              user_id = "ALEX";
   5.147              email = "pep.test.alexander3@darthmama.org";
   5.148              key_prefix = "pep.test.alexander3-0x724B3975";
   5.149 +            fpr = "5F7076BBD92E14EA49F0DF7C2CE49419724B3975";
   5.150              break;
   5.151          case ALEX_4:
   5.152              name = "Alex Braithwaite";
   5.153              user_id = "ALEX";
   5.154              email = "pep.test.alexander4@darthmama.org";
   5.155              key_prefix = "pep.test.alexander4-0x844B9DCF";
   5.156 +            fpr = "E95FFF95B8E2FDD4A12C3374395F1485844B9DCF";
   5.157              break;
   5.158          case ALEX_5:
   5.159              name = "Alex Braithwaite";
   5.160              user_id = "ALEX";
   5.161              email = "pep.test.alexander5@darthmama.org";
   5.162              key_prefix = "pep.test.alexander5-0x0773CD29";
   5.163 +            fpr = "58BCC2BF2AE1E3C4FBEAB89AD7838ACA0773CD29";
   5.164              break;
   5.165          case ALEX_6A:
   5.166              name = "Alex Braithwaite";
   5.167              user_id = "ALEX";
   5.168              email = "pep.test.alexander6@darthmama.org";
   5.169              key_prefix = "pep.test.alexander6-0x0019697D";
   5.170 +            fpr = "74D79B4496E289BD8A71B70BA8E2C4530019697D";
   5.171              break;
   5.172          case ALEX_6B:
   5.173              name = "Alex Braithwaite";
   5.174              user_id = "ALEX";
   5.175              email = "pep.test.alexander6@darthmama.org";
   5.176              key_prefix = "pep.test.alexander6-0x503B14D8";
   5.177 +            fpr = "2E21325D202A44BFD9C607FCF095B202503B14D8";
   5.178              break;
   5.179          case ALEX_6C:
   5.180              name = "Alex Braithwaite";
   5.181              user_id = "ALEX";
   5.182              email = "pep.test.alexander6@darthmama.org";
   5.183              key_prefix = "pep.test.alexander6-0xA216E95A";
   5.184 +            fpr = "3C1E713D8519D7F907E3142D179EAA24A216E95A";
   5.185              break;
   5.186          case ALEX_6D:
   5.187              name = "Alex Braithwaite";
   5.188              user_id = "ALEX";
   5.189              email = "pep.test.alexander6@darthmama.org";
   5.190              key_prefix = "pep.test.alexander6-0xBDA17020";
   5.191 +            fpr = "B4CE2F6947B6947C500F0687AEFDE530BDA17020";
   5.192              break;
   5.193          case BELLA:
   5.194              name = "Bella Cat";
   5.195              user_id = "BELLA";
   5.196              email = "pep.test.bella@peptest.ch";
   5.197              key_prefix = "pep.test.bella-0xAF516AAE";
   5.198 +            fpr = "5631BF1357326A02AA470EEEB815EF7FA4516AAE";
   5.199              break;
   5.200          case FENRIS:
   5.201              name = "Fenris Leto Hawke";
   5.202              user_id = "FENRIS";
   5.203              email = "pep.test.fenris@thisstilldoesntwork.lu";
   5.204              key_prefix = "pep.test.fenris-0x4F3D2900";
   5.205 +            fpr = "0969FA229DF21C832A64A04711B1B9804F3D2900";
   5.206              break;
   5.207          case SERCULLEN:
   5.208              name = "Cullen Rutherford";
   5.209              user_id = "CULLEN";
   5.210              email = "sercullen-test@darthmama.org";
   5.211 -            key_prefix = "sercullen-0x3CEAADED4"; // NB expired
   5.212 +            key_prefix = "sercullen-0x3CEAADED4"; // NB expired on purpose
   5.213 +            fpr = "1C9666D8B3E28F4AA3847DA89A6E75E3CEAADED4";
   5.214              break;
   5.215          case INQUISITOR:
   5.216              name = "Inquisitor Claire Trevelyan";
   5.217              user_id = "INQUISITOR";
   5.218              email = "inquisitor@darthmama.org";
   5.219              key_prefix = "inquisitor-0xA4728718_renewed";
   5.220 +            fpr = "8E8D2381AE066ABE1FEE509821BA977CA4728718";
   5.221              break;
   5.222          case BERND:
   5.223              name = "Bernd das Brot";
   5.224              user_id = "BERNDI";
   5.225              email = "bernd.das.brot@darthmama.org";
   5.226              key_prefix = "bernd.das.brot-0xCAFAA422";
   5.227 +            fpr = "F8CE0F7E24EB190A2FCBFD38D4B088A7CAFAA422";
   5.228              break;
   5.229          default:
   5.230              return PEP_CANNOT_SET_IDENTITY;
   5.231 @@ -871,11 +903,11 @@
   5.232      string pubkey_file = pubkey_dir + key_prefix + "_pub.asc";
   5.233      string privkey_file = privkey_dir + key_prefix + "_priv.asc";
   5.234      
   5.235 -    if (!slurp_and_import_key(session, pubkey_file.c_str())
   5.236 +    if (!slurp_and_import_key(session, pubkey_file.c_str()))
   5.237          return PEP_KEY_NOT_FOUND;
   5.238  
   5.239 -    if (private) {    
   5.240 -        if (!slurp_and_import_key(session, privkey_file.c_str())
   5.241 +    if (setup_private) {    
   5.242 +        if (!slurp_and_import_key(session, privkey_file.c_str()))
   5.243              return PEP_KEY_NOT_FOUND;
   5.244      }
   5.245  
   5.246 @@ -883,10 +915,32 @@
   5.247      if (!retval)
   5.248          return PEP_OUT_OF_MEMORY;
   5.249      
   5.250 -    retval->me = set_own;
   5.251 +    if (set_own) {
   5.252 +        retval->me = true;
   5.253 +        status = set_own_key(session, retval, fpr);
   5.254 +    }        
   5.255      
   5.256 +    if (set_pep && status == PEP_STATUS_OK)
   5.257 +        status = set_as_pEp_user(session, retval);
   5.258 +    if (trust && status == PEP_STATUS_OK) {
   5.259 +        if (!retval->me)
   5.260 +            status = update_identity(session, retval);
   5.261 +        if (retval->comm_type >= PEP_ct_strong_but_unconfirmed) {
   5.262 +            retval->comm_type = (PEP_comm_type)(retval->comm_type | PEP_ct_confirmed);
   5.263 +            status = set_trust(session, retval);
   5.264 +        }
   5.265 +    }
   5.266      
   5.267 +    // honestly probably happens anyway  
   5.268 +    if (set_ident && status == PEP_STATUS_OK)
   5.269 +        status = set_identity(session, retval);
   5.270      
   5.271 +    if (ident)
   5.272 +        *ident = retval;
   5.273 +    else 
   5.274 +        free_identity(retval);
   5.275 +        
   5.276 +    return status;
   5.277  }
   5.278  
   5.279  #endif