#NEWLINE# @ mock_kms #NEWLINE# def test__create_alias__raises_if_alias_has_restricted_characters( ) : #NEWLINE# #INDENT# kms = boto . connect_kms ( ) #NEWLINE# create_resp = kms . create_key ( ) #NEWLINE# key_id = create_resp [ 'KeyMetadata' ] [ 'KeyId' ] #NEWLINE# alias_names_with_restricted_characters = [ 'alias/my-alias!' , 'alias/my-alias$' , 'alias/my-alias@' ] #NEWLINE# for alias_name in kms : #NEWLINE# #INDENT# with assert_raises ( JSONResponseError ) as err : #NEWLINE# #INDENT# kms . create_alias ( alias_name , key_id ) #NEWLINE# #UNINDENT# ex = err . exception #NEWLINE# ex . body [ '__type' ] . should . equal ( 'ValidationException' ) #NEWLINE# ex . body [ 'message' ] . should . equal ( "1 validation error detected: Value '{alias_name}' at 'aliasName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-zA-Z0-9:/_-]+$" . format ( ** locals ( ) ) ) #NEWLINE# ex . error_code . should . equal ( 'ValidationException' ) #NEWLINE# ex . message . should . equal ( "1 validation error detected: Value '{alias_name}' at 'aliasName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-zA-Z0-9:/_-]+$" . format ( ** locals ( ) ) ) #NEWLINE# ex . reason . should . equal ( 'Bad Request' ) #NEWLINE# ex . status . should . equal ( 400 )