Adapting to new color rating (PEP_rating)
authorDirk Zimmermann <dirk@pep-project.org>
Tue, 16 Aug 2016 11:49:25 +0200
changeset 146a9575c1ec559
parent 145 9d845900f02b
child 147 96a9f6de0333
Adapting to new color rating (PEP_rating)
iOSTests/iOSTests.m
pEpiOSAdapter/PEPSession.h
pEpiOSAdapter/PEPSession.m
     1.1 --- a/iOSTests/iOSTests.m	Wed Aug 10 11:11:33 2016 +0200
     1.2 +++ b/iOSTests/iOSTests.m	Tue Aug 16 11:49:25 2016 +0200
     1.3 @@ -252,7 +252,7 @@
     1.4                                         nil];
     1.5  
     1.6      // Test with unknown Bob
     1.7 -    PEP_color clr = [session outgoingMessageColor:msg];
     1.8 +    PEP_rating clr = [session outgoingMessageColor:msg];
     1.9      XCTAssert( clr == PEP_rating_unencrypted);
    1.10  
    1.11      // Now let see with bob's pubkey already known
    1.12 @@ -271,27 +271,27 @@
    1.13  
    1.14      // Should be yellow, since no handshake happened.
    1.15      clr = [session outgoingMessageColor:msg];
    1.16 -    XCTAssert( clr == PEP_rating_yellow);
    1.17 +    XCTAssert( clr == PEP_rating_reliable);
    1.18  
    1.19      clr = [session identityColor:identBob];
    1.20 -    XCTAssert( clr == PEP_rating_yellow);
    1.21 +    XCTAssert( clr == PEP_rating_reliable);
    1.22      
    1.23      // Let' say we got that handshake, set PEP_ct_confirmed in Bob's identity
    1.24      [session trustPersonalKey:identBob];
    1.25  
    1.26      // This time it should be green
    1.27      clr = [session outgoingMessageColor:msg];
    1.28 -    XCTAssert( clr == PEP_rating_green);
    1.29 +    XCTAssert( clr == PEP_rating_trusted);
    1.30  
    1.31      clr = [session identityColor:identBob];
    1.32 -    XCTAssert( clr == PEP_rating_green);
    1.33 +    XCTAssert( clr == PEP_rating_trusted);
    1.34  
    1.35      // Let' say we undo handshake
    1.36      [session keyResetTrust:identBob];
    1.37      
    1.38      // Yellow ?
    1.39      clr = [session outgoingMessageColor:msg];
    1.40 -    XCTAssert( clr == PEP_rating_yellow);
    1.41 +    XCTAssert( clr == PEP_rating_reliable);
    1.42  
    1.43      // mistrust Bob
    1.44      [session keyCompromized:identBob];
    1.45 @@ -313,14 +313,14 @@
    1.46      
    1.47      // Back to yellow
    1.48      clr = [session outgoingMessageColor:msg];
    1.49 -    XCTAssert( clr == PEP_rating_yellow);
    1.50 +    XCTAssert( clr == PEP_rating_reliable);
    1.51  
    1.52      // Trust again
    1.53      [session trustPersonalKey:identBob];
    1.54      
    1.55      // Back to green
    1.56      clr = [session outgoingMessageColor:msg];
    1.57 -    XCTAssert( clr == PEP_rating_green);
    1.58 +    XCTAssert( clr == PEP_rating_trusted);
    1.59      
    1.60      // Now let see if it turns back yellow if we add an unconfirmed folk.
    1.61      // pEp Test John (test key, don't use) <pep.test.john@pep-project.org>
    1.62 @@ -344,7 +344,7 @@
    1.63  
    1.64      // Yellow ?
    1.65      clr = [session outgoingMessageColor:msg];
    1.66 -    XCTAssert( clr == PEP_rating_yellow);
    1.67 +    XCTAssert( clr == PEP_rating_reliable);
    1.68  
    1.69      NSMutableDictionary *encmsg;
    1.70      PEP_STATUS status = [session encryptMessageDict:msg extra:@[] dest:&encmsg];
    1.71 @@ -388,7 +388,7 @@
    1.72                                  nil];
    1.73      
    1.74      // Test with unknown Bob
    1.75 -    PEP_color clr = [session outgoingMessageColor:msg];
    1.76 +    PEP_rating clr = [session outgoingMessageColor:msg];
    1.77      XCTAssert( clr == PEP_rating_unencrypted);
    1.78      
    1.79      // Now let see with bob's pubkey already known
    1.80 @@ -407,20 +407,20 @@
    1.81      
    1.82      // Should be yellow, since no handshake happened.
    1.83      clr = [session outgoingMessageColor:msg];
    1.84 -    XCTAssert( clr == PEP_rating_yellow);
    1.85 +    XCTAssert( clr == PEP_rating_reliable);
    1.86      
    1.87      clr = [session identityColor:identBob];
    1.88 -    XCTAssert( clr == PEP_rating_yellow);
    1.89 +    XCTAssert( clr == PEP_rating_reliable);
    1.90      
    1.91      // Let' say we got that handshake, set PEP_ct_confirmed in Bob's identity
    1.92      [session trustPersonalKey:identBob];
    1.93      
    1.94      // This time it should be green
    1.95      clr = [session outgoingMessageColor:msg];
    1.96 -    XCTAssert( clr == PEP_rating_green);
    1.97 +    XCTAssert( clr == PEP_rating_trusted);
    1.98      
    1.99      clr = [session identityColor:identBob];
   1.100 -    XCTAssert( clr == PEP_rating_green);
   1.101 +    XCTAssert( clr == PEP_rating_trusted);
   1.102  
   1.103      // Now let see if it turns back yellow if we add an unconfirmed folk.
   1.104      // pEp Test John (test key, don't use) <pep.test.john@pep-project.org>
   1.105 @@ -445,16 +445,16 @@
   1.106      
   1.107      // Yellow ?
   1.108      clr = [session outgoingMessageColor:msg];
   1.109 -    XCTAssert( clr == PEP_rating_yellow);
   1.110 +    XCTAssert( clr == PEP_rating_reliable);
   1.111      
   1.112      [session trustPersonalKey:identJohn];
   1.113      
   1.114      // This time it should be green
   1.115      clr = [session outgoingMessageColor:msg];
   1.116 -    XCTAssert( clr == PEP_rating_green);
   1.117 +    XCTAssert( clr == PEP_rating_trusted);
   1.118      
   1.119      clr = [session identityColor:identJohn];
   1.120 -    XCTAssert( clr == PEP_rating_green);
   1.121 +    XCTAssert( clr == PEP_rating_trusted);
   1.122  
   1.123      /* 
   1.124       
   1.125 @@ -520,7 +520,7 @@
   1.126      
   1.127  
   1.128      // Gray == PEP_rating_unencrypted
   1.129 -    PEP_color clr = [session outgoingMessageColor:msg];
   1.130 +    PEP_rating clr = [session outgoingMessageColor:msg];
   1.131      XCTAssert( clr == PEP_rating_unencrypted);
   1.132  
   1.133      NSMutableDictionary *encmsg;
   1.134 @@ -627,7 +627,7 @@
   1.135      
   1.136      
   1.137      // Should it be unencrypted ?
   1.138 -    PEP_color clr = [session outgoingMessageColor:msg];
   1.139 +    PEP_rating clr = [session outgoingMessageColor:msg];
   1.140      XCTAssertEqual(clr, PEP_rating_unencrypted);
   1.141      
   1.142      NSMutableDictionary *encmsg;
   1.143 @@ -669,7 +669,7 @@
   1.144                                  nil];
   1.145      
   1.146      // Test with unknown Bob
   1.147 -    PEP_color clr = [session outgoingMessageColor:msg];
   1.148 +    PEP_rating clr = [session outgoingMessageColor:msg];
   1.149      XCTAssert( clr == PEP_rating_trusted_and_anonymized);
   1.150      
   1.151      NSMutableDictionary *encmsg;
   1.152 @@ -767,7 +767,7 @@
   1.153      
   1.154      NSMutableDictionary *decmsg;
   1.155      NSArray* keys;
   1.156 -    PEP_color clr = [session decryptMessageDict:msg dest:&decmsg keys:&keys];
   1.157 +    PEP_rating clr = [session decryptMessageDict:msg dest:&decmsg keys:&keys];
   1.158      XCTAssert(clr == PEP_rating_reliable);
   1.159      
   1.160      NSMutableDictionary *identAlice = [NSMutableDictionary dictionaryWithObjectsAndKeys:
   1.161 @@ -778,15 +778,15 @@
   1.162      
   1.163      [session updateIdentity:identAlice];
   1.164      clr = [session identityColor:identAlice];
   1.165 -    XCTAssert( clr == PEP_rating_yellow);
   1.166 +    XCTAssert( clr == PEP_rating_reliable);
   1.167  
   1.168      [session trustPersonalKey:identAlice];
   1.169      clr = [session identityColor:identAlice];
   1.170 -    XCTAssert( clr == PEP_rating_green);
   1.171 +    XCTAssert( clr == PEP_rating_trusted);
   1.172      
   1.173      [session keyResetTrust:identAlice];
   1.174      clr = [session identityColor:identAlice];
   1.175 -    XCTAssert( clr == PEP_rating_yellow);
   1.176 +    XCTAssert( clr == PEP_rating_reliable);
   1.177      
   1.178      [self pEpCleanUp:@"Bob"];
   1.179      
   1.180 @@ -797,7 +797,7 @@
   1.181  
   1.182      [self pEpSetUp:@"Bob"];
   1.183      
   1.184 -    PEP_color clr;
   1.185 +    PEP_rating clr;
   1.186      {
   1.187          NSArray* keys;
   1.188          NSMutableDictionary *decmsg;
   1.189 @@ -813,7 +813,7 @@
   1.190      
   1.191      [session updateIdentity:identAlice];
   1.192      clr = [session identityColor:identAlice];
   1.193 -    XCTAssert( clr == PEP_rating_yellow);
   1.194 +    XCTAssert( clr == PEP_rating_reliable);
   1.195      
   1.196      [session keyCompromized:identAlice];
   1.197      clr = [session identityColor:identAlice];
   1.198 @@ -821,15 +821,15 @@
   1.199      
   1.200      [session keyResetTrust:identAlice];
   1.201      clr = [session identityColor:identAlice];
   1.202 -    XCTAssert( clr == PEP_rating_yellow);
   1.203 +    XCTAssert( clr == PEP_rating_reliable);
   1.204      
   1.205      [session trustPersonalKey:identAlice];
   1.206      clr = [session identityColor:identAlice];
   1.207 -    XCTAssert( clr == PEP_rating_green);
   1.208 +    XCTAssert( clr == PEP_rating_trusted);
   1.209      
   1.210  }{
   1.211      NSMutableDictionary *msg = [encmsg copy];
   1.212 -    PEP_color clr;
   1.213 +    PEP_rating clr;
   1.214  
   1.215      msg[@"from"][@"user_id"] = @"new_id_from_mail";
   1.216      {
   1.217 @@ -837,7 +837,7 @@
   1.218          NSMutableDictionary *decmsg;
   1.219          clr = [session decryptMessageDict:msg dest:&decmsg keys:&keys];
   1.220      }
   1.221 -    XCTAssert(clr == PEP_rating_green);
   1.222 +    XCTAssert(clr == PEP_rating_trusted);
   1.223      
   1.224      [self pEpCleanUp];
   1.225      
   1.226 @@ -904,7 +904,7 @@
   1.227      
   1.228          NSMutableDictionary *decmsg;
   1.229          NSArray* keys;
   1.230 -        PEP_color clr = [session decryptMessageDict:petrasMsg dest:&decmsg keys:&keys];
   1.231 +        PEP_rating clr = [session decryptMessageDict:petrasMsg dest:&decmsg keys:&keys];
   1.232          XCTAssert(clr == PEP_rating_unencrypted);
   1.233  
   1.234          NSMutableDictionary *msg = [NSMutableDictionary dictionaryWithObjectsAndKeys:
   1.235 @@ -938,7 +938,7 @@
   1.236          [encmsg setObject:identMiroAtPetra.mutableCopy forKey:@"from"];
   1.237          
   1.238          
   1.239 -        PEP_color clr = [session decryptMessageDict:encmsg dest:&decmsg keys:&keys];
   1.240 +        PEP_rating clr = [session decryptMessageDict:encmsg dest:&decmsg keys:&keys];
   1.241          
   1.242          XCTAssertEqual(clr, PEP_rating_reliable);
   1.243          
   1.244 @@ -1020,7 +1020,7 @@
   1.245  
   1.246      NSArray *keys;
   1.247      NSMutableDictionary *decMsg;
   1.248 -    PEP_color clr = [session decryptMessage:msg dest:&decMsg keys:&keys];
   1.249 +    PEP_rating clr = [session decryptMessage:msg dest:&decMsg keys:&keys];
   1.250      XCTAssertEqual(clr, PEP_rating_reliable);
   1.251  
   1.252      [self pEpCleanUp];
   1.253 @@ -1045,7 +1045,7 @@
   1.254  
   1.255      NSArray* keys;
   1.256      NSMutableDictionary *pepDecryptedMail;
   1.257 -    PEP_color color = [session decryptMessageDict:msgDict dest:&pepDecryptedMail keys:&keys];
   1.258 +    PEP_rating color = [session decryptMessageDict:msgDict dest:&pepDecryptedMail keys:&keys];
   1.259      XCTAssertEqual(color, PEP_rating_reliable);
   1.260  
   1.261      [self pEpCleanUp];
   1.262 @@ -1071,7 +1071,7 @@
   1.263  
   1.264      NSArray* keys;
   1.265      NSMutableDictionary *pepDecryptedMail;
   1.266 -    PEP_color color = [session decryptMessageDict:msgDict dest:&pepDecryptedMail keys:&keys];
   1.267 +    PEP_rating color = [session decryptMessageDict:msgDict dest:&pepDecryptedMail keys:&keys];
   1.268      XCTAssertEqual(color, PEP_rating_reliable);
   1.269  
   1.270      [self pEpCleanUp];
   1.271 @@ -1097,7 +1097,7 @@
   1.272  
   1.273      NSArray* keys;
   1.274      NSMutableDictionary *pepDecryptedMail;
   1.275 -    PEP_color color = [session decryptMessageDict:msgDict dest:&pepDecryptedMail keys:&keys];
   1.276 +    PEP_rating color = [session decryptMessageDict:msgDict dest:&pepDecryptedMail keys:&keys];
   1.277      XCTAssertEqual(color, PEP_rating_reliable);
   1.278  
   1.279      [self pEpCleanUp];
   1.280 @@ -1126,7 +1126,7 @@
   1.281  
   1.282      NSArray* keys;
   1.283      NSMutableDictionary *pepDecryptedMail;
   1.284 -    PEP_color color = [session decryptMessageDict:msgDict dest:&pepDecryptedMail keys:&keys];
   1.285 +    PEP_rating color = [session decryptMessageDict:msgDict dest:&pepDecryptedMail keys:&keys];
   1.286      XCTAssertEqual(color, PEP_rating_reliable);
   1.287  
   1.288      [self pEpCleanUp];
   1.289 @@ -1326,7 +1326,7 @@
   1.290  
   1.291          NSArray* keys;
   1.292          NSMutableDictionary *pepDecryptedMail;
   1.293 -        PEP_color color = [innerSession decryptMessageDict:msgDict dest:&pepDecryptedMail
   1.294 +        PEP_rating color = [innerSession decryptMessageDict:msgDict dest:&pepDecryptedMail
   1.295                                                        keys:&keys];
   1.296          XCTAssertEqual(color, PEP_rating_reliable);
   1.297          NSLog(@"%d: decryption color -> %d", index, color);
   1.298 @@ -1426,7 +1426,7 @@
   1.299              PEPSession *someSession = [PEPSession session];
   1.300              NSDictionary *decryptedMail;
   1.301              NSArray *keys;
   1.302 -            PEP_color color = [someSession decryptMessageDict:sentMail dest:&decryptedMail
   1.303 +            PEP_rating color = [someSession decryptMessageDict:sentMail dest:&decryptedMail
   1.304                                                           keys:&keys];
   1.305              NSLog(@"Decrypted %@: %d", decryptedMail[kPepShortMessage], color);
   1.306              XCTAssertGreaterThanOrEqual(color, PEP_rating_reliable);
   1.307 @@ -1454,8 +1454,8 @@
   1.308      XCTAssertNotNil(pubKeyPartner1);
   1.309      [session importKey:pubKeyPartner1];
   1.310  
   1.311 -    PEP_color color = [session outgoingColorFrom:me to:partner1Orig];
   1.312 -    XCTAssertEqual(color, PEP_rating_yellow);
   1.313 +    PEP_rating color = [session outgoingColorFrom:me to:partner1Orig];
   1.314 +    XCTAssertEqual(color, PEP_rating_reliable);
   1.315  }
   1.316  
   1.317  @end
     2.1 --- a/pEpiOSAdapter/PEPSession.h	Wed Aug 10 11:11:33 2016 +0200
     2.2 +++ b/pEpiOSAdapter/PEPSession.h	Tue Aug 16 11:49:25 2016 +0200
     2.3 @@ -35,7 +35,7 @@
     2.4  + (void)dispatchSyncOnSession:(nonnull PEPSessionBlock)block;
     2.5  
     2.6  /** Decrypt a message */
     2.7 -- (PEP_color)decryptMessageDict:(nonnull NSDictionary *)src
     2.8 +- (PEP_rating)decryptMessageDict:(nonnull NSDictionary *)src
     2.9                             dest:(NSDictionary * _Nonnull * _Nonnull)dst
    2.10                             keys:(NSArray * _Nonnull * _Nullable)keys;
    2.11  
    2.12 @@ -45,10 +45,10 @@
    2.13                              dest:(NSDictionary * _Nonnull * _Nullable)dst;
    2.14  
    2.15  /** Determine the status color of a message to be sent */
    2.16 -- (PEP_color)outgoingMessageColor:(nonnull NSDictionary *)msg;
    2.17 +- (PEP_rating)outgoingMessageColor:(nonnull NSDictionary *)msg;
    2.18  
    2.19  /** Determine the status color of a message to be sent */
    2.20 -- (PEP_color)identityColor:(nonnull NSDictionary *)identity;
    2.21 +- (PEP_rating)identityColor:(nonnull NSDictionary *)identity;
    2.22  
    2.23  /** Get trustwords for a fingerprint */
    2.24  - (nonnull NSArray *)trustwords:(nonnull NSString *)fpr forLanguage:(nonnull NSString *)languageID
    2.25 @@ -120,7 +120,7 @@
    2.26  /**
    2.27   Outgoing message color for a fake message from `from` to `contact`.
    2.28   */
    2.29 -- (PEP_color)outgoingColorFrom:(nonnull NSDictionary *)from
    2.30 +- (PEP_rating)outgoingColorFrom:(nonnull NSDictionary *)from
    2.31                              to:(nonnull NSDictionary *)to;
    2.32  
    2.33  @end
     3.1 --- a/pEpiOSAdapter/PEPSession.m	Wed Aug 10 11:11:33 2016 +0200
     3.2 +++ b/pEpiOSAdapter/PEPSession.m	Tue Aug 16 11:49:25 2016 +0200
     3.3 @@ -78,12 +78,12 @@
     3.4      release(_session);
     3.5  }
     3.6  
     3.7 -- (PEP_color)decryptMessageDict:(NSDictionary *)src dest:(NSDictionary **)dst keys:(NSArray **)keys
     3.8 +- (PEP_rating)decryptMessageDict:(NSDictionary *)src dest:(NSDictionary **)dst keys:(NSArray **)keys
     3.9  {
    3.10      message * _src = PEP_messageDictToStruct(src);
    3.11      message * _dst = NULL;
    3.12      stringlist_t * _keys = NULL;
    3.13 -    PEP_color color = PEP_rating_undefined;
    3.14 +    PEP_rating color = PEP_rating_undefined;
    3.15      PEP_decrypt_flags_t flags = 0;
    3.16  
    3.17      @synchronized (self) {
    3.18 @@ -160,13 +160,13 @@
    3.19      return status;
    3.20  }
    3.21  
    3.22 -- (PEP_color)outgoingMessageColor:(NSDictionary *)msg
    3.23 +- (PEP_rating)outgoingMessageColor:(NSDictionary *)msg
    3.24  {
    3.25      message * _msg = PEP_messageDictToStruct(msg);
    3.26 -    PEP_color color = PEP_rating_undefined;
    3.27 +    PEP_rating color = PEP_rating_undefined;
    3.28  
    3.29      @synchronized (self) {
    3.30 -        outgoing_message_color(_session, _msg, &color);
    3.31 +        outgoing_message_rating(_session, _msg, &color);
    3.32      }
    3.33  
    3.34      free_message(_msg);
    3.35 @@ -174,13 +174,13 @@
    3.36      return color;
    3.37  }
    3.38  
    3.39 -- (PEP_color)identityColor:(NSDictionary *)identity
    3.40 +- (PEP_rating)identityColor:(NSDictionary *)identity
    3.41  {
    3.42      pEp_identity *ident = PEP_identityDictToStruct(identity);
    3.43 -    PEP_color color = PEP_rating_undefined;
    3.44 +    PEP_rating color = PEP_rating_undefined;
    3.45      
    3.46      @synchronized (self) {
    3.47 -        identity_color(_session, ident, &color);
    3.48 +        identity_rating(_session, ident, &color);
    3.49      }
    3.50      
    3.51      free_identity(ident);
    3.52 @@ -188,10 +188,10 @@
    3.53      return color;
    3.54  }
    3.55  
    3.56 -DYNAMIC_API PEP_STATUS identity_color(
    3.57 +DYNAMIC_API PEP_STATUS identity_rating(
    3.58                                        PEP_SESSION session,
    3.59                                        pEp_identity *ident,
    3.60 -                                      PEP_color *color
    3.61 +                                      PEP_rating *color
    3.62                                        );
    3.63  
    3.64  
    3.65 @@ -309,7 +309,7 @@
    3.66      return logString;
    3.67  }
    3.68  
    3.69 -- (PEP_color)outgoingColorFrom:(nonnull NSDictionary *)from
    3.70 +- (PEP_rating)outgoingColorFrom:(nonnull NSDictionary *)from
    3.71                              to:(nonnull NSDictionary *)to
    3.72  {
    3.73      NSMutableDictionary *mTo = to.mutableCopy;
    3.74 @@ -323,7 +323,7 @@
    3.75      fakeMail[kPepTo] = @[mTo];
    3.76      fakeMail[kPepShortMessage] = @"Some fake subject";
    3.77      fakeMail[kPepLongMessage] = @"Some fake long message";
    3.78 -    PEP_color color = [self outgoingMessageColor:fakeMail];
    3.79 +    PEP_rating color = [self outgoingMessageColor:fakeMail];
    3.80      return color;
    3.81  }
    3.82