def test_encrypt_with_latest_key(self): badkey = resource('__nonexistant__.key') goodkey = resource('inapp-sample-pay.key') with mock.patch.object(settings, 'INAPP_KEY_PATHS', {'2012-05-09': badkey, '2012-05-10': goodkey}): sk = 'your coat is hidden under the stairs' self.inapp.set_private_key(sk) eq_(self.inapp.get_private_key(), sk)
def test_encrypt_with_latest_key(self): badkey = resource('__nonexistant__.key') goodkey = resource('inapp-sample-pay.key') with mock.patch.object(settings, 'INAPP_KEY_PATHS', { '2012-05-09': badkey, '2012-05-10': goodkey }): sk = 'your coat is hidden under the stairs' self.inapp.set_private_key(sk) eq_(self.inapp.get_private_key(), sk)
def test_pin_to_corect_key(self): sk = 'your coat is hidden under the stairs' altkey = resource('inapp-sample-pay-alt.key') goodkey = resource('inapp-sample-pay.key') with mock.patch.object(settings, 'INAPP_KEY_PATHS', {'2012-05-09': altkey}): self.inapp.set_private_key(sk) eq_(self.inapp.get_private_key(), sk) self.inapp = InappConfig.objects.get(pk=self.inapp.pk) with mock.patch.object(settings, 'INAPP_KEY_PATHS', {'2012-05-09': altkey, '2012-05-10': goodkey}): eq_(self.inapp.get_private_key(), sk)
def test_pin_to_corect_key(self): sk = 'your coat is hidden under the stairs' altkey = resource('inapp-sample-pay-alt.key') goodkey = resource('inapp-sample-pay.key') with mock.patch.object(settings, 'INAPP_KEY_PATHS', {'2012-05-09': altkey}): self.inapp.set_private_key(sk) eq_(self.inapp.get_private_key(), sk) self.inapp = InappConfig.objects.get(pk=self.inapp.pk) with mock.patch.object(settings, 'INAPP_KEY_PATHS', { '2012-05-09': altkey, '2012-05-10': goodkey }): eq_(self.inapp.get_private_key(), sk)
def test_wrong_key(self): sk = 'your coat is hidden under the stairs' self.inapp.set_private_key(sk) altkey = resource('inapp-sample-pay-alt.key') with mock.patch.object(settings, 'INAPP_KEY_PATHS', {'2012-05-09': altkey}): self.inapp.get_private_key()
def test_migrate(self): with mock.patch.object(settings, 'INAPP_KEY_PATHS', {'2012-05-10': resource('inapp-sample-pay.key')}): cfg = create_inapp_config() old_key = cfg.get_private_key() old_raw_key = cfg._encrypted_private_key cfg = InappConfig.uncached.get(pk=cfg.pk) eq_(cfg.key_timestamp, '2012-05-10') with mock.patch.object(settings, 'INAPP_KEY_PATHS', {'2012-05-10': resource('inapp-sample-pay.key'), '2012-05-11': resource('inapp-sample-pay-alt.key')}): Command().handle(old_timestamp='2012-05-10', new_timestamp='2012-05-11') cfg = InappConfig.uncached.get(pk=cfg.pk) eq_(cfg.get_private_key(), old_key) new_raw_key = cfg._encrypted_private_key assert new_raw_key != old_raw_key, ('raw keys were changed') eq_(cfg.key_timestamp, '2012-05-11')