Skip to content

Commit

Permalink
Add a test case for a failed integrity check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kami committed Mar 18, 2019
1 parent b77e98a commit 17427bf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions st2api/tests/unit/controllers/v1/test_kvps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import copy

from tests import FunctionalTest

from st2common.models.db.auth import UserDB
Expand Down Expand Up @@ -541,6 +543,25 @@ def test_put_encrypted_value(self):
self.assertEqual(get_resp.json['value'], 'S3cret!Value')
self.__do_delete(self.__get_kvp_id(put_resp))

def test_put_encrypted_value_integrity_check_failed(self):
data = copy.deepcopy(ENCRYPTED_KVP)
data['value'] = 'corrupted'
put_resp = self.__do_put('secret_key1', data, expect_errors=True)
self.assertEqual(put_resp.status_code, 400)

expected_error = ('Failed to verify the integrity of the provided value for key '
'"secret_key1".')
self.assertTrue(expected_error in put_resp.json['faultstring'])

data = copy.deepcopy(ENCRYPTED_KVP)
data['value'] = str(data['value'][:-2])
put_resp = self.__do_put('secret_key1', data, expect_errors=True)
self.assertEqual(put_resp.status_code, 400)

expected_error = ('Failed to verify the integrity of the provided value for key '
'"secret_key1".')
self.assertTrue(expected_error in put_resp.json['faultstring'])

def test_put_delete(self):
put_resp = self.__do_put('key1', KVP)
self.assertEqual(put_resp.status_int, 200)
Expand Down

0 comments on commit 17427bf

Please sign in to comment.