@@ -814,37 +814,54 @@ def create_package(parameter_hash)
814814 end
815815 end
816816
817- context 'when the error_on_password_parameter option is set to false' do
817+ context 'password parameter validations' do
818+ password_parameter_error_message = 'Password parameter type can no longer be used'
819+ password_parameter_warning_message = 'Password parameter type is deprecated and will not be accepted in the future'
820+
821+ context 'when the error_on_password_parameter option is set to false' do
822+ describe 'when the password parameter type is present' do
823+ it 'should be valid but add a warning about the password param type' do
824+ error_on_password_parameter = false
825+ @manifest_hash = {
826+ 'parameters' => [
827+ 'name' => 'a password param' ,
828+ 'type' => 'password' ,
829+ ] }
830+ package = create_package ( @manifest_hash )
831+ errors = ZendeskAppsSupport ::Validations ::Manifest . call ( package , error_on_password_parameter : error_on_password_parameter )
832+
833+ expect ( errors . map ( &:to_s ) . join ( ) ) . not_to include ( password_parameter_error_message )
834+ expect ( package . warnings . join ( ) ) . to include ( password_parameter_warning_message )
835+ end
836+ end
818837
819- it 'should be valid but add a warning about the password param type' do
820- error_on_password_parameter = false
821- @manifest_hash = {
822- 'parameters' => [
823- 'name' => 'a password param' ,
824- 'type' => 'password' ,
825- ] }
826- package = create_package ( @manifest_hash )
827- errors = ZendeskAppsSupport ::Validations ::Manifest . call ( package , error_on_password_parameter : error_on_password_parameter )
838+ describe 'when the password parameter type is not present' do
839+ it 'should be valid and add no warnings about a password parameter' do
840+ error_on_password_parameter = false
841+ @manifest_hash = { }
842+ package = create_package ( @manifest_hash )
843+ errors = ZendeskAppsSupport ::Validations ::Manifest . call ( package , error_on_password_parameter : error_on_password_parameter )
828844
829- expect ( errors . map ( &:to_s ) . join ( ) ) . not_to include ( "Password parameter type can no longer be used" )
830- expect ( package . warnings . join ( ) ) . to include ( "Password parameter type is deprecated and will not be accepted in the future" )
845+ expect ( errors . map ( &:to_s ) . join ( ) ) . not_to include ( password_parameter_error_message )
846+ expect ( package . warnings . join ( ) ) . not_to include ( password_parameter_warning_message )
847+ end
848+ end
831849 end
832- end
833850
834- context 'when the error_on_password_parameter option is set to true' do
835-
836- it 'should not be valid with a password param type and add no warnings' do
837- error_on_password_parameter = true
838- @manifest_hash = {
839- 'parameters' => [
840- 'name ' => 'a password param ' ,
841- 'type' => 'password' ,
842- ] }
843- package = create_package ( @manifest_hash )
844- errors = ZendeskAppsSupport :: Validations :: Manifest . call ( package , error_on_password_parameter : error_on_password_parameter )
845-
846- expect ( errors . map ( & :to_s ) . join ( ) ) . to include ( "Password parameter type can no longer be used" )
847- expect ( package . warnings . join ( ) ) . not_to include ( "Password parameter type is deprecated and will not be accepted in the future" )
851+ context 'when the error_on_password_parameter option is set to true' do
852+ it 'should not be valid with a password param type and add no warnings' do
853+ error_on_password_parameter = true
854+ @manifest_hash = {
855+ 'parameters' => [
856+ 'name' => 'a password param' ,
857+ 'type ' => 'password' ,
858+ ] }
859+ package = create_package ( @manifest_hash )
860+ errors = ZendeskAppsSupport :: Validations :: Manifest . call ( package , error_on_password_parameter : error_on_password_parameter )
861+
862+ expect ( errors . map ( & :to_s ) . join ( ) ) . to include ( password_parameter_error_message )
863+ expect ( package . warnings . join ( ) ) . not_to include ( password_parameter_warning_message )
864+ end
848865 end
849866 end
850867end
0 commit comments