test/src/util/test_util.cc
branchENGINE-434
changeset 2677 a1ade141a1d1
parent 2635 04e6df2957e8
child 2679 567462e5b11a
     1.1 --- a/test/src/util/test_util.cc	Fri May 11 09:06:29 2018 +0200
     1.2 +++ b/test/src/util/test_util.cc	Fri May 18 10:19:50 2018 +0200
     1.3 @@ -137,6 +137,12 @@
     1.4              return "PEP_DECRYPT_NO_KEY";
     1.5          case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH:
     1.6              return "PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH";
     1.7 +        case PEP_DECRYPTED_BUT_UNSIGNED:
     1.8 +            return "PEP_DECRYPTED_BUT_UNSIGNED";
     1.9 +        case PEP_DECRYPT_MODIFICATION_DETECTED:
    1.10 +            return "PEP_DECRYPT_MODIFICATION_DETECTED";
    1.11 +        case PEP_DECRYPT_NO_KEY_FOR_SIGNER:
    1.12 +            return "PEP_DECRYPT_NO_KEY_FOR_SIGNER";
    1.13          case PEP_VERIFY_NO_KEY:
    1.14              return "PEP_VERIFY_NO_KEY";
    1.15          case PEP_VERIFIED_AND_TRUSTED:
    1.16 @@ -204,7 +210,7 @@
    1.17          case PEP_OUT_OF_MEMORY:
    1.18              return "PEP_OUT_OF_MEMORY";
    1.19          case PEP_UNKNOWN_ERROR:
    1.20 -            return "PEP_UNKNOWN_ERROR";
    1.21 +            return "PEP_UNKNOWN_ERROR";    
    1.22          default:
    1.23   
    1.24              return "PEP_STATUS_OMGWTFBBQ - This means you're using a status the test lib doesn't know about!";
    1.25 @@ -317,3 +323,13 @@
    1.26              return "PEP_ct_OMGWTFBBQ\n\nIn other words, comm type is invalid. Either something's corrupt or a new ct value has been added to the enum but not to the test function.";
    1.27      }
    1.28  }
    1.29 +
    1.30 +bool slurp_message_and_import_key(PEP_SESSION session, const char* message_fname, std::string& message, const char* key_filename) {
    1.31 +    message = slurp(message_fname);
    1.32 +    if (key_filename) {
    1.33 +        std::string keyfile = slurp(key_filename);
    1.34 +        if (import_key(session, keyfile.c_str(), keyfile.size(), NULL) != PEP_STATUS_OK)
    1.35 +            return false;
    1.36 +    }
    1.37 +    return true;
    1.38 +}