예제 #1
0
    def test_save(self):
        """Setup the test cases"""
        SecureString.create(MY_STRING, NAME).save()

        with self.assertRaises(Exception):
            SecureString.create(unencrypted="", name=NAME).save()

        with self.assertRaises(Exception):
            SecureString(encrypted_string='something', name=NAME).save()
예제 #2
0
    def test_save(self):
        """Setup the test cases"""
        SecureString.create(MY_STRING, NAME).save()

        with self.assertRaises(Exception):
            SecureString.create(name=NAME).save()

        with self.assertRaises(Exception):
            SecureString(encrypted_string='something', name=NAME).save()
예제 #3
0
파일: models.py 프로젝트: tw7649116/TS
 def save(self, *args, **kwargs):
     """Override the default save behavior to also include the secure secret"""
     password = kwargs.pop('password', '')
     super(ThermoFisherCloudAccount, self).save(*args, **kwargs)
     if password:
         secret = SecureString.create(password, self.ampliseq_secret_name)
         secret.save()
예제 #4
0
파일: api.py 프로젝트: iontorrent/TS
    def obj_create(self, bundle, request=None, **kwargs):
        """Custom create method to override the default post"""

        try:
            params = bundle.data
            # sanity check on the input parameters
            if 'encrypted_string' in params:
                del params['encrypted_string']
            if 'unencrypted' not in params:
                return HttpApplicationError("API creation of SecureString requires \'unencrypted\' parameter")
            if 'name' not in params:
                return HttpApplicationError("API creation of SecureString requires \'name\' parameter")

            # create and save the new object
            try:
                secured = SecureString.objects.get(name=params['name'])
                secured.encrypt(params['unencrypted'])
                secured.save()
            except SecureString.DoesNotExist:
                secured = SecureString.create(params['unencrypted'], params['name'])
                secured.save()

            return bundle
        except Exception as exc:
            logger.debug(str(exc))
            return HttpApplicationError("Error creating secure string: " + str(exc))
예제 #5
0
파일: api.py 프로젝트: Tiredbird/TS
    def obj_create(self, bundle, request=None, **kwargs):
        """Custom create method to override the default post"""

        try:
            params = bundle.data
            # sanity check on the input parameters
            if 'encrypted_string' in params:
                del params['encrypted_string']
            if 'unencrypted' not in params:
                return HttpApplicationError(
                    "API creation of SecureString requires \'unencrypted\' parameter"
                )
            if 'name' not in params:
                return HttpApplicationError(
                    "API creation of SecureString requires \'name\' parameter")

            # create and save the new object
            try:
                secured = SecureString.objects.get(name=params['name'])
                secured.encrypt(params['unencrypted'])
                secured.save()
            except SecureString.DoesNotExist:
                secured = SecureString.create(params['unencrypted'],
                                              params['name'])
                secured.save()

            return bundle
        except Exception as exc:
            logger.debug(str(exc))
            return HttpApplicationError("Error creating secure string: " +
                                        str(exc))
예제 #6
0
    def test_create(self):
        """test the objects create method"""
        self.assertIsNotNone(SecureString.create(unencrypted=MY_STRING, name=NAME))

        with self.assertRaises(Exception):
            SecureString.objects.create(name=NAME)

        with self.assertRaises(TypeError):
            SecureString.objects.create(password=MY_STRING, name=NAME)
예제 #7
0
    def test_create(self):
        """test the objects create method"""
        self.assertIsNotNone(SecureString.create(unencrypted=MY_STRING, name=NAME))

        with self.assertRaises(Exception):
            SecureString.objects.create(name=NAME)

        with self.assertRaises(TypeError):
            SecureString.objects.create(password=MY_STRING, name=NAME)
예제 #8
0
 def test_created(self):
     SecureString.create(MY_STRING, NAME).save()
     self.assertIsNotNone(SecureString.objects.get(name=NAME).created)
예제 #9
0
    def test_decrypt(self):
        """tests the get method"""

        SecureString.create(MY_STRING, NAME).save()
        sp = SecureString.objects.get(name=NAME)
        self.assertEqual(sp.decrypted, MY_STRING)
예제 #10
0
 def test_get(self):
     """tests the get method"""
     SecureString.create(MY_STRING, NAME).save()
     self.assertIsNotNone(SecureString.objects.get(name=NAME))
예제 #11
0
 def test_created(self):
     SecureString.create(MY_STRING, NAME).save()
     self.assertIsNotNone(SecureString.objects.get(name=NAME).created)
예제 #12
0
    def test_decrypt(self):
        """tests the get method"""

        SecureString.create(MY_STRING, NAME).save()
        sp = SecureString.objects.get(name=NAME)
        self.assertEqual(sp.decrypted, MY_STRING)
예제 #13
0
 def test_get(self):
     """tests the get method"""
     SecureString.create(MY_STRING, NAME).save()
     self.assertIsNotNone(SecureString.objects.get(name=NAME))