diff --git a/.credo.exs b/.credo.exs index e6f1abb..00925bb 100644 --- a/.credo.exs +++ b/.credo.exs @@ -10,7 +10,7 @@ configs: [ %{ # - # Run any exec using `mix credo -C `. If no exec name is given + # Run any config using `mix credo -C `. If no config name is given # "default" is used. # name: "default", @@ -21,10 +21,23 @@ # You can give explicit globs or simply directories. # In the latter case `**/*.{ex,exs}` will be used. # - included: ["lib/", "src/", "test/", "web/", "apps/"], + included: [ + "lib/", + "src/", + "test/", + "web/", + "apps/*/lib/", + "apps/*/src/", + "apps/*/test/", + "apps/*/web/" + ], excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"] }, # + # Load and configure plugins here: + # + plugins: [], + # # If you create your own checks, you must specify the source files for # them here, so they can be loaded by Credo before running the analysis. # @@ -35,6 +48,10 @@ # strict: false, # + # To modify the timeout for parsing files, change this value: + # + parse_timeout: 5000, + # # If you want to use uncolored output by default, you can change `color` # to `false` below: # @@ -47,109 +64,158 @@ # # {Credo.Check.Design.DuplicatedCode, false} # - checks: [ - # - ## Consistency Checks - # - {Credo.Check.Consistency.ExceptionNames, []}, - {Credo.Check.Consistency.LineEndings, []}, - {Credo.Check.Consistency.ParameterPatternMatching, []}, - {Credo.Check.Consistency.SpaceAroundOperators, []}, - {Credo.Check.Consistency.SpaceInParentheses, []}, - {Credo.Check.Consistency.TabsOrSpaces, []}, + checks: %{ + enabled: [ + # + ## Consistency Checks + # + {Credo.Check.Consistency.ExceptionNames, []}, + {Credo.Check.Consistency.LineEndings, []}, + {Credo.Check.Consistency.ParameterPatternMatching, []}, + {Credo.Check.Consistency.SpaceAroundOperators, []}, + {Credo.Check.Consistency.SpaceInParentheses, []}, + {Credo.Check.Consistency.TabsOrSpaces, []}, - # - ## Design Checks - # - # You can customize the priority of any check - # Priority values are: `low, normal, high, higher` - # - {Credo.Check.Design.AliasUsage, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]}, - # You can also customize the exit_status of each check. - # If you don't want TODO comments to cause `mix credo` to fail, just - # set this value to 0 (zero). - # - {Credo.Check.Design.TagTODO, [exit_status: 2]}, - {Credo.Check.Design.TagFIXME, []}, + # + ## Design Checks + # + # You can customize the priority of any check + # Priority values are: `low, normal, high, higher` + # + {Credo.Check.Design.AliasUsage, + [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]}, + {Credo.Check.Design.TagFIXME, []}, + # You can also customize the exit_status of each check. + # If you don't want TODO comments to cause `mix credo` to fail, just + # set this value to 0 (zero). + # + {Credo.Check.Design.TagTODO, [exit_status: 2]}, - # - ## Readability Checks - # - {Credo.Check.Readability.AliasOrder, []}, - {Credo.Check.Readability.FunctionNames, []}, - {Credo.Check.Readability.LargeNumbers, []}, - {Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]}, - {Credo.Check.Readability.ModuleAttributeNames, []}, - {Credo.Check.Readability.ModuleDoc, []}, - {Credo.Check.Readability.ModuleNames, []}, - {Credo.Check.Readability.ParenthesesInCondition, []}, - {Credo.Check.Readability.ParenthesesOnZeroArityDefs, []}, - {Credo.Check.Readability.PredicateFunctionNames, []}, - {Credo.Check.Readability.PreferImplicitTry, []}, - {Credo.Check.Readability.RedundantBlankLines, []}, - {Credo.Check.Readability.Semicolons, []}, - {Credo.Check.Readability.SpaceAfterCommas, []}, - {Credo.Check.Readability.StringSigils, []}, - {Credo.Check.Readability.TrailingBlankLine, []}, - {Credo.Check.Readability.TrailingWhiteSpace, []}, - {Credo.Check.Readability.VariableNames, []}, + # + ## Readability Checks + # + {Credo.Check.Readability.AliasOrder, []}, + {Credo.Check.Readability.FunctionNames, []}, + {Credo.Check.Readability.LargeNumbers, []}, + {Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]}, + {Credo.Check.Readability.ModuleAttributeNames, []}, + {Credo.Check.Readability.ModuleDoc, []}, + {Credo.Check.Readability.ModuleNames, []}, + {Credo.Check.Readability.ParenthesesInCondition, []}, + {Credo.Check.Readability.ParenthesesOnZeroArityDefs, []}, + {Credo.Check.Readability.PipeIntoAnonymousFunctions, []}, + {Credo.Check.Readability.PredicateFunctionNames, []}, + {Credo.Check.Readability.PreferImplicitTry, []}, + {Credo.Check.Readability.RedundantBlankLines, []}, + {Credo.Check.Readability.Semicolons, []}, + {Credo.Check.Readability.SpaceAfterCommas, []}, + {Credo.Check.Readability.StringSigils, []}, + {Credo.Check.Readability.TrailingBlankLine, []}, + {Credo.Check.Readability.TrailingWhiteSpace, []}, + {Credo.Check.Readability.UnnecessaryAliasExpansion, []}, + {Credo.Check.Readability.VariableNames, []}, + {Credo.Check.Readability.WithSingleClause, []}, - # - ## Refactoring Opportunities - # - {Credo.Check.Refactor.CondStatements, []}, - {Credo.Check.Refactor.CyclomaticComplexity, []}, - {Credo.Check.Refactor.FunctionArity, []}, - {Credo.Check.Refactor.LongQuoteBlocks, []}, - {Credo.Check.Refactor.MapInto, false}, - {Credo.Check.Refactor.MatchInCondition, []}, - {Credo.Check.Refactor.NegatedConditionsInUnless, []}, - {Credo.Check.Refactor.NegatedConditionsWithElse, []}, - {Credo.Check.Refactor.Nesting, []}, - {Credo.Check.Refactor.PipeChainStart, - [ - excluded_argument_types: [:atom, :binary, :fn, :keyword, :number], - excluded_functions: [] - ]}, - {Credo.Check.Refactor.UnlessWithElse, []}, + # + ## Refactoring Opportunities + # + {Credo.Check.Refactor.Apply, []}, + {Credo.Check.Refactor.CondStatements, []}, + {Credo.Check.Refactor.CyclomaticComplexity, []}, + {Credo.Check.Refactor.FilterCount, []}, + {Credo.Check.Refactor.FilterFilter, []}, + {Credo.Check.Refactor.FunctionArity, []}, + {Credo.Check.Refactor.LongQuoteBlocks, []}, + {Credo.Check.Refactor.MapJoin, []}, + {Credo.Check.Refactor.MatchInCondition, []}, + {Credo.Check.Refactor.NegatedConditionsInUnless, []}, + {Credo.Check.Refactor.NegatedConditionsWithElse, []}, + {Credo.Check.Refactor.Nesting, []}, + {Credo.Check.Refactor.RedundantWithClauseResult, []}, + {Credo.Check.Refactor.RejectReject, []}, + {Credo.Check.Refactor.UnlessWithElse, []}, + {Credo.Check.Refactor.WithClauses, []}, - # - ## Warnings - # - {Credo.Check.Warning.BoolOperationOnSameValues, []}, - {Credo.Check.Warning.ExpensiveEmptyEnumCheck, []}, - {Credo.Check.Warning.IExPry, []}, - {Credo.Check.Warning.IoInspect, []}, - {Credo.Check.Warning.LazyLogging, []}, - {Credo.Check.Warning.OperationOnSameValues, []}, - {Credo.Check.Warning.OperationWithConstantResult, []}, - {Credo.Check.Warning.RaiseInsideRescue, []}, - {Credo.Check.Warning.UnusedEnumOperation, []}, - {Credo.Check.Warning.UnusedFileOperation, []}, - {Credo.Check.Warning.UnusedKeywordOperation, []}, - {Credo.Check.Warning.UnusedListOperation, []}, - {Credo.Check.Warning.UnusedPathOperation, []}, - {Credo.Check.Warning.UnusedRegexOperation, []}, - {Credo.Check.Warning.UnusedStringOperation, []}, - {Credo.Check.Warning.UnusedTupleOperation, []}, + # + ## Warnings + # + {Credo.Check.Warning.ApplicationConfigInModuleAttribute, []}, + {Credo.Check.Warning.BoolOperationOnSameValues, []}, + {Credo.Check.Warning.Dbg, []}, + {Credo.Check.Warning.ExpensiveEmptyEnumCheck, []}, + {Credo.Check.Warning.IExPry, []}, + {Credo.Check.Warning.IoInspect, []}, + {Credo.Check.Warning.MissedMetadataKeyInLoggerConfig, []}, + {Credo.Check.Warning.OperationOnSameValues, []}, + {Credo.Check.Warning.OperationWithConstantResult, []}, + {Credo.Check.Warning.RaiseInsideRescue, []}, + {Credo.Check.Warning.SpecWithStruct, []}, + {Credo.Check.Warning.StructFieldAmount, []}, + {Credo.Check.Warning.UnsafeExec, []}, + {Credo.Check.Warning.UnusedEnumOperation, []}, + {Credo.Check.Warning.UnusedFileOperation, []}, + {Credo.Check.Warning.UnusedKeywordOperation, []}, + {Credo.Check.Warning.UnusedListOperation, []}, + {Credo.Check.Warning.UnusedMapOperation, []}, + {Credo.Check.Warning.UnusedPathOperation, []}, + {Credo.Check.Warning.UnusedRegexOperation, []}, + {Credo.Check.Warning.UnusedStringOperation, []}, + {Credo.Check.Warning.UnusedTupleOperation, []}, + {Credo.Check.Warning.WrongTestFilename, []} + ], + disabled: [ + # + # Checks scheduled for next check update (opt-in for now) + {Credo.Check.Refactor.UtcNowTruncate, []}, - # - # Controversial and experimental checks (opt-in, just remove `, false`) - # - {Credo.Check.Consistency.MultiAliasImportRequireUse, false}, - {Credo.Check.Design.DuplicatedCode, false}, - {Credo.Check.Readability.Specs, false}, - {Credo.Check.Refactor.ABCSize, false}, - {Credo.Check.Refactor.AppendSingleItem, false}, - {Credo.Check.Refactor.DoubleBooleanNegation, false}, - {Credo.Check.Refactor.VariableRebinding, false}, - {Credo.Check.Warning.MapGetUnsafePass, false}, - {Credo.Check.Warning.UnsafeToAtom, false} + # + # Controversial and experimental checks (opt-in, just move the check to `:enabled` + # and be sure to use `mix credo --strict` to see low priority checks) + # + {Credo.Check.Consistency.MultiAliasImportRequireUse, []}, + {Credo.Check.Consistency.UnusedVariableNames, []}, + {Credo.Check.Design.DuplicatedCode, []}, + {Credo.Check.Design.SkipTestWithoutComment, []}, + {Credo.Check.Readability.AliasAs, []}, + {Credo.Check.Readability.BlockPipe, []}, + {Credo.Check.Readability.ImplTrue, []}, + {Credo.Check.Readability.MultiAlias, []}, + {Credo.Check.Readability.NestedFunctionCalls, []}, + {Credo.Check.Readability.OneArityFunctionInPipe, []}, + {Credo.Check.Readability.OnePipePerLine, []}, + {Credo.Check.Readability.SeparateAliasRequire, []}, + {Credo.Check.Readability.SingleFunctionToBlockPipe, []}, + {Credo.Check.Readability.SinglePipe, []}, + {Credo.Check.Readability.Specs, []}, + {Credo.Check.Readability.StrictModuleLayout, []}, + {Credo.Check.Readability.WithCustomTaggedTuple, []}, + {Credo.Check.Refactor.ABCSize, []}, + {Credo.Check.Refactor.AppendSingleItem, []}, + {Credo.Check.Refactor.CondInsteadOfIfElse, []}, + {Credo.Check.Refactor.DoubleBooleanNegation, []}, + {Credo.Check.Refactor.FilterReject, []}, + {Credo.Check.Refactor.IoPuts, []}, + {Credo.Check.Refactor.MapMap, []}, + {Credo.Check.Refactor.ModuleDependencies, []}, + {Credo.Check.Refactor.NegatedIsNil, []}, + {Credo.Check.Refactor.PassAsyncInTestCases, []}, + {Credo.Check.Refactor.PipeChainStart, []}, + {Credo.Check.Refactor.RejectFilter, []}, + {Credo.Check.Refactor.VariableRebinding, []}, + {Credo.Check.Warning.LazyLogging, []}, + {Credo.Check.Warning.LeakyEnvironment, []}, + {Credo.Check.Warning.MapGetUnsafePass, []}, + {Credo.Check.Warning.MixEnv, []}, + {Credo.Check.Warning.UnsafeToAtom, []} + # {Credo.Check.Warning.UnusedOperation, [{MyMagicModule, [:fun1, :fun2]}]} - # - # Custom checks can be created using `mix credo.gen.check`. - # - ] + # {Credo.Check.Refactor.MapInto, []}, + + # + # Custom checks can be created using `mix credo.gen.check`. + # + ] + } } ] -} +} \ No newline at end of file diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..3c838cf --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +erlang 28.5.0.2 +elixir 1.20.2-otp-28 \ No newline at end of file diff --git a/README.md b/README.md index bc436ea..3005779 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,14 @@ iex> {:ok, response} = Soap.call(wsdl, action, params) }} ``` +Safe strings: + +You might have strings that you know are safe where you'd like to skip the escaping step in generating the XML (for example if you have a lot of Base64 encoded data). For this situation you can mark data as "safe": + +```elixir +params = %{data: {:__safe, data}} +``` + Parse response: ```elixir diff --git a/lib/soap/request/params.ex b/lib/soap/request/params.ex index 7f10aa8..1d4dc28 100644 --- a/lib/soap/request/params.ex +++ b/lib/soap/request/params.ex @@ -38,7 +38,7 @@ defmodule Soap.Request.Params do @spec validate_params(params :: any(), wsdl :: map(), operation :: String.t()) :: any() def validate_params(params, _wsdl, _operation) when is_binary(params), do: params - def validate_params({_tag, _attrs, _nested} = param, wsdl, operation) do + def validate_params(param = {_tag, _attrs, _nested}, wsdl, operation) do case validate_param(param, wsdl, operation) do nil -> param error -> {:error, error} @@ -90,6 +90,7 @@ defmodule Soap.Request.Params do validate_type(k, v, type) end + defp validate_type(k, {:safe, v}, type), do: validate_type(k, v, type) defp validate_type(_k, v, "string") when is_binary(v), do: nil defp validate_type(k, _v, type = "string"), do: type_error_message(k, type) @@ -132,18 +133,13 @@ defmodule Soap.Request.Params do end defp build_soap_header(wsdl, operation, headers) do - case headers |> construct_xml_request_header do - {:error, messages} -> - {:error, messages} - - validated_params -> - body = - validated_params - |> add_header_part_tag_wrapper(wsdl, operation) - |> add_header_tag_wrapper + body = + headers + |> construct_xml_request_header + |> add_header_part_tag_wrapper(wsdl, operation) + |> add_header_tag_wrapper - {:ok, body} - end + {:ok, body} end defp type_error_message(k, type) do @@ -159,44 +155,37 @@ defmodule Soap.Request.Params do params |> Enum.map(&construct_xml_request_body/1) end - @spec construct_xml_request_body(params :: tuple()) :: tuple() - defp construct_xml_request_body({tag, attrs, nested}) do - [{to_string(tag), attrs, construct_xml_request_body(nested)}] + defp construct_xml_request_body({:__safe, value}), do: {:safe, value} + + defp construct_xml_request_body({tag, value}) do + {to_string(tag), nil, construct_xml_request_body(value)} end - defp construct_xml_request_body(params) when is_tuple(params) do - params - |> Tuple.to_list() - |> Enum.map(&construct_xml_request_body/1) - |> insert_tag_parameters - |> List.to_tuple() + @spec construct_xml_request_body({term(), term()}) :: {term(), term()} + defp construct_xml_request_body({tag, attrs, nested}) do + [{to_string(tag), attrs, construct_xml_request_body(nested)}] end @spec construct_xml_request_body(params :: String.t() | atom() | number()) :: String.t() defp construct_xml_request_body(params) when is_atom(params), do: params |> to_string() defp construct_xml_request_body(params) when is_binary(params) or is_number(params), do: params + # defp construct_xml_request_header({:__safe, value}), do: {:safe, value} + + @spec construct_xml_request_header({term(), term()}) :: {term(), term()} + defp construct_xml_request_header({tag, value}) do + {to_string(tag), nil, construct_xml_request_header(value)} + end + @spec construct_xml_request_header(params :: map() | list()) :: list() defp construct_xml_request_header(params) when is_map(params) or is_list(params) do params |> Enum.map(&construct_xml_request_header/1) end - @spec construct_xml_request_header(params :: tuple()) :: tuple() - defp construct_xml_request_header(params) when is_tuple(params) do - params - |> Tuple.to_list() - |> Enum.map(&construct_xml_request_header/1) - |> insert_tag_parameters - |> List.to_tuple() - end - @spec construct_xml_request_header(params :: String.t() | atom() | number()) :: String.t() defp construct_xml_request_header(params) when is_atom(params) or is_number(params), do: params |> to_string defp construct_xml_request_header(params) when is_binary(params), do: params - @spec insert_tag_parameters(params :: list()) :: list() - defp insert_tag_parameters(params) when is_list(params), do: params |> List.insert_at(1, nil) - @spec add_action_tag_wrapper(list(), map(), String.t()) :: list() defp add_action_tag_wrapper(body, wsdl, operation) do action_tag_attributes = handle_element_form_default(wsdl[:schema_attributes]) @@ -276,10 +265,10 @@ defmodule Soap.Request.Params do end @spec add_body_tag_wrapper(list()) :: list() - defp add_body_tag_wrapper(body), do: [element(:"#{env_namespace()}:Body", nil, body)] + defp add_body_tag_wrapper(body), do: [element("#{env_namespace()}:Body", nil, body)] @spec add_header_tag_wrapper(list()) :: list() - defp add_header_tag_wrapper(body), do: [element(:"#{env_namespace()}:Header", nil, body)] + defp add_header_tag_wrapper(body), do: [element("#{env_namespace()}:Header", nil, body)] @spec add_envelope_tag_wrapper(body :: any(), wsdl :: map(), operation :: String.t()) :: any() defp add_envelope_tag_wrapper(body, wsdl, operation) do @@ -289,7 +278,7 @@ defmodule Soap.Request.Params do |> Map.merge(build_action_attribute(wsdl, operation)) |> Map.merge(custom_namespaces()) - [element(:"#{env_namespace()}:Envelope", envelop_attributes, body)] + [element("#{env_namespace()}:Envelope", envelop_attributes, body)] end @spec build_soap_version_attribute(map()) :: map() diff --git a/lib/soap/type.ex b/lib/soap/type.ex index 0e6a588..01fa001 100644 --- a/lib/soap/type.ex +++ b/lib/soap/type.ex @@ -5,7 +5,7 @@ defmodule Soap.Type do import SweetXml, except: [parse: 1] - @spec get_complex_types(String.t(), String.t()) :: map() + @spec get_complex_types(tuple() | String.t(), String.t()) :: map() def get_complex_types(wsdl, x_path) do wsdl |> xpath(~x"#{x_path}"l) diff --git a/lib/soap/wsdl.ex b/lib/soap/wsdl.ex index 439ab17..12f1f3e 100644 --- a/lib/soap/wsdl.ex +++ b/lib/soap/wsdl.ex @@ -11,13 +11,16 @@ defmodule Soap.Wsdl do alias Soap.{Request, Type, Xsd} - @spec parse_from_file(String.t()) :: {:ok, map()} + @typep xml_element :: tuple() + @typep ns_prefix :: charlist() | atom() + + @spec parse_from_file(String.t(), keyword()) :: {:ok, map()} def parse_from_file(path, opts \\ []) do {:ok, wsdl} = File.read(path) parse(wsdl, path, opts) end - @spec parse_from_url(String.t()) :: {:ok, map()} + @spec parse_from_url(String.t(), keyword()) :: {:ok, map()} def parse_from_url(path, opts \\ []) do request_opts = Keyword.merge([follow_redirect: true, max_redirect: 5], opts) %HTTPoison.Response{body: wsdl} = Request.get_http_client().get!(path, [], request_opts) @@ -47,7 +50,7 @@ defmodule Soap.Wsdl do {:ok, parsed_response} end - @spec get_schema_namespace(String.t()) :: String.t() + @spec get_schema_namespace(xml_element()) :: ns_prefix() defp get_schema_namespace(wsdl) do {_, _, _, schema_namespace, _} = wsdl @@ -57,14 +60,14 @@ defmodule Soap.Wsdl do schema_namespace end - @spec get_namespaces(String.t(), String.t(), String.t()) :: map() + @spec get_namespaces(xml_element(), ns_prefix(), ns_prefix()) :: map() defp get_namespaces(wsdl, schema_namespace, protocol_ns) do wsdl |> xpath(~x"//#{ns("definitions", protocol_ns)}/namespace::*"l) |> Enum.into(%{}, &get_namespace(&1, wsdl, schema_namespace, protocol_ns)) end - @spec get_namespace(tuple(), String.t(), String.t(), String.t()) :: tuple() + @spec get_namespace(tuple(), xml_element(), ns_prefix(), ns_prefix()) :: tuple() defp get_namespace(namespaces_node, wsdl, schema_namespace, protocol_ns) do {_, _, _, key, value} = namespaces_node string_key = key |> to_string @@ -87,7 +90,7 @@ defmodule Soap.Wsdl do end end - @spec get_endpoint(String.t(), String.t(), String.t()) :: String.t() + @spec get_endpoint(xml_element(), ns_prefix(), ns_prefix()) :: String.t() def get_endpoint(wsdl, protocol_ns, soap_ns) do wsdl |> xpath( @@ -97,7 +100,7 @@ defmodule Soap.Wsdl do ) end - @spec get_complex_types(String.t(), String.t(), String.t()) :: list() + @spec get_complex_types(xml_element(), ns_prefix(), ns_prefix()) :: list() defp get_complex_types(wsdl, namespace, protocol_ns) do xpath( wsdl, @@ -107,7 +110,7 @@ defmodule Soap.Wsdl do ) end - @spec get_validation_types(String.t(), String.t(), String.t(), String.t(), String.t(), keyword()) :: map() + @spec get_validation_types(xml_element(), String.t(), ns_prefix(), ns_prefix(), String.t(), keyword()) :: map() def get_validation_types(wsdl, file_path, protocol_ns, schema_ns, endpoint, opts \\ []) do Map.merge( Type.get_complex_types( @@ -121,7 +124,7 @@ defmodule Soap.Wsdl do ) end - @spec get_schema_imports(String.t(), String.t(), String.t()) :: list() + @spec get_schema_imports(xml_element(), ns_prefix(), ns_prefix()) :: list() def get_schema_imports(wsdl, protocol_ns, schema_ns) do xpath( wsdl, @@ -130,7 +133,7 @@ defmodule Soap.Wsdl do ) end - @spec get_full_paths(String.t(), String.t(), String.t(), String.t(), String.t()) :: list(String.t()) + @spec get_full_paths(xml_element(), String.t(), ns_prefix(), ns_prefix(), String.t()) :: list(String.t()) defp get_full_paths(wsdl, path, protocol_ns, schema_namespace, endpoint) do wsdl |> get_schema_imports(protocol_ns, schema_namespace) @@ -213,7 +216,7 @@ defmodule Soap.Wsdl do xpath(element, ~x"./#{ns("part", protocol_ns)}"l, name: ~x"./@name"s, element: ~x"./@element"s) end - @spec get_protocol_namespace(String.t()) :: String.t() + @spec get_protocol_namespace(xml_element()) :: ns_prefix() defp get_protocol_namespace(wsdl) do wsdl |> xpath(~x"//namespace::*"l) @@ -221,7 +224,7 @@ defmodule Soap.Wsdl do |> elem(3) end - @spec get_soap_namespace(String.t(), list()) :: String.t() + @spec get_soap_namespace(xml_element(), list()) :: ns_prefix() defp get_soap_namespace(wsdl, opts) when is_list(opts) do version = soap_version(opts) namespace = @soap_version_namespaces[version] @@ -232,7 +235,7 @@ defmodule Soap.Wsdl do |> elem(3) end - @spec get_schema_attributes(String.t()) :: map() + @spec get_schema_attributes(xml_element()) :: map() defp get_schema_attributes(wsdl) do case xpath(wsdl, ~x"//*[local-name() = 'schema']") do nil -> diff --git a/mix.exs b/mix.exs index 58ef0a4..be6daa7 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Soap.MixProject do use Mix.Project @source_url "https://github.com/elixir-soap/soap" - @version "1.1.0" + @version "1.1.1" def project do [ @@ -14,8 +14,13 @@ defmodule Soap.MixProject do deps: deps(), docs: docs(), package: package(), - test_coverage: [tool: ExCoveralls], - preferred_cli_env: [ + test_coverage: [tool: ExCoveralls] + ] + end + + def cli do + [ + preferred_envs: [ coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, @@ -45,11 +50,12 @@ defmodule Soap.MixProject do defp deps do [ + {:decimal, "~> 3.0"}, {:sweet_xml, "~> 0.6"}, - {:dialyxir, "~> 1.1.0", only: [:dev, :test], runtime: false}, + {:dialyxir, "~> 1.4.7", only: [:dev, :test], runtime: false}, # Http && XML - {:httpoison, "~> 1.3"}, + {:httpoison, "~> 1.0 or ~> 2.0 or ~> 3.0"}, {:xml_builder, "~> 2.1"}, {:credo, "~> 1.0", only: [:dev, :test]}, {:ex_doc, ">= 0.0.0", only: [:dev, :docs], runtime: false}, diff --git a/mix.lock b/mix.lock index 71b3b0a..b3e0c2a 100644 --- a/mix.lock +++ b/mix.lock @@ -1,28 +1,32 @@ %{ - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "certifi": {:hex, :certifi, "2.8.0", "d4fb0a6bb20b7c9c3643e22507e42f356ac090a1dcea9ab99e27e0376d695eba", [:rebar3], [], "hexpm", "6ac7efc1c6f8600b08d625292d4bbf584e14847ce1b6b5c44d983d273e1097ea"}, - "credo": {:hex, :credo, "1.6.1", "7dc76dcdb764a4316c1596804c48eada9fff44bd4b733a91ccbf0c0f368be61e", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "698607fb5993720c7e93d2d8e76f2175bba024de964e160e2f7151ef3ab82ac5"}, - "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.18", "e1b2be73eb08a49fb032a0208bf647380682374a725dfb5b9e510def8397f6f2", [:mix], [], "hexpm", "114a0e85ec3cf9e04b811009e73c206394ffecfcc313e0b346de0d557774ee97"}, - "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"}, - "excoveralls": {:hex, :excoveralls, "0.14.4", "295498f1ae47bdc6dce59af9a585c381e1aefc63298d48172efaaa90c3d251db", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e3ab02f2df4c1c7a519728a6f0a747e71d7d6e846020aae338173619217931c1"}, - "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, - "hackney": {:hex, :hackney, "1.18.0", "c4443d960bb9fba6d01161d01cd81173089686717d9490e5d3606644c48d121f", [:rebar3], [{:certifi, "~>2.8.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "9afcda620704d720db8c6a3123e9848d09c87586dc1c10479c42627b905b5c5e"}, - "httpoison": {:hex, :httpoison, "1.8.0", "6b85dea15820b7804ef607ff78406ab449dd78bed923a49c7160e1886e987a3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "28089eaa98cf90c66265b6b5ad87c59a3729bea2e74e9d08f9b51eb9729b3c3a"}, - "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, - "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, - "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, - "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, + "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, + "certifi": {:hex, :certifi, "2.17.0", "835748414307e15e05b17d0e518190228ce648b08d569a5cc93a85a40f3e5c9b", [:rebar3], [], "hexpm", "8122798a17f0293c80daada25d0f81c7f4d708c73fef782c7c9b1950e26e4d21"}, + "credo": {:hex, :credo, "1.7.19", "cc52129665fc7c15143d47838fda0f9cd6dac9ceced7bf4da6f85fcbfe64b12a", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "2d8bc95d5a7bb99dd2613621d4f08c6a3575c3fd4b62e6a2b48a100352a557b8"}, + "decimal": {:hex, :decimal, "3.1.1", "430d87b04011ce6cbd4fd205be758311a81f87d552d40904abd00f015935b1d0", [:mix], [], "hexpm", "c5f25f2ced74a0587d03e6023f595db8e924c9d3922c8c8ffd9edfc4498cf1f6"}, + "dialyxir": {:hex, :dialyxir, "1.4.7", "dda948fcee52962e4b6c5b4b16b2d8fa7d50d8645bbae8b8685c3f9ecb7f5f4d", [:mix], [{:erlex, ">= 0.2.8", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b34527202e6eb8cee198efec110996c25c5898f43a4094df157f8d28f27d9efe"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.45", "cba8369ab2a1342e419bc2760eec731b17be828941dcf494045d44766227e1d5", [:mix], [], "hexpm", "d3ec045bf122965db20c0bdb420e19ee1415843135327124918473feb4b328e8"}, + "erlex": {:hex, :erlex, "0.2.9", "7debbbaa9f4f368b8cd648983e0f1d7963028508e9c59e9d4ed504e94ef52a55", [:mix], [], "hexpm", "8cfffc0ec7159e6d73de2ab28a588064de80f88b2798d5cbe4482cbbc200178b"}, + "ex_doc": {:hex, :ex_doc, "0.40.3", "4a972ffe64bc07dc605af487e98fc19b72a4185f55ca031b94c0552d6071c1d9", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "2756e357742fecd9749b489b85d67c9ce99c465f2e75728d9e6dc8d704b973de"}, + "excoveralls": {:hex, :excoveralls, "0.18.5", "e229d0a65982613332ec30f07940038fe451a2e5b29bce2a5022165f0c9b157e", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "523fe8a15603f86d64852aab2abe8ddbd78e68579c8525ae765facc5eae01562"}, + "file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"}, + "h2": {:hex, :h2, "0.10.2", "ea0146b9c8b5f3b5de16045765f5684db38ef1e66f1c60444890948cb1003e47", [:rebar3], [], "hexpm", "497a899f338b42e6a0b292524e635b0ce6f9379fa39395c8e38d06351cd9b9cf"}, + "hackney": {:hex, :hackney, "4.4.5", "a908f620525bb886a16613532324762e5166287f8c00c9888a762edee11a30c0", [:rebar3], [{:certifi, "~> 2.17.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:h2, "~> 0.10.1", [hex: :h2, repo: "hexpm", optional: false]}, {:idna, "~> 7.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.4", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.2", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:quic, "~> 1.6.5", [hex: :quic, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:webtransport, "~> 0.4.1", [hex: :webtransport, repo: "hexpm", optional: false]}], "hexpm", "6d72bef4e135e94c522c271e11fbb6933efb0006ef235a3933807d0be73b71ec"}, + "httpoison": {:hex, :httpoison, "3.0.0", "8566a933bb9175236d1ec335978445b67cd1f5b5d3ead6ca4b80be469d41f5d9", [:mix], [{:hackney, "~> 4.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "9130197b7658901c493d6fcfb842fb9676300fa8a6c8ed058c8889cf1a77f3c2"}, + "idna": {:hex, :idna, "7.1.0", "1067a13043538129602d2f2ce6899d8713125c7d19734aa557ce2e3ea55bd4f1", [:rebar3], [], "hexpm", "6ae959a025bf36df61a8cab8508d9654891b5426a84c44d82deaffd6ddf8c71f"}, + "jason": {:hex, :jason, "1.4.5", "2e3a008590b0b8d7388c20293e9dcc9cf3e5d642fd2a114e4cbbb52e595d940a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b0c823996102bcd0239b3c2444eb00409b72f6a140c1950bc8b457d836b30684"}, + "makeup": {:hex, :makeup, "1.2.2", "882d46dc0905e9ff7abf2aab61a7e6b3dcc555533977d8a23b06019e6c89ac94", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "9a1a24e5b343b8ae16abea0822c10a6f75da27af7fa802ada5251f7579bfccfa"}, + "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.1.0", "835f7e60792e08824cda445639555d7bf1bbbddb1b60b306e33cb6f6db24dc74", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "1cd6780fb1dd1a03979abaed0fe82712b0625118fd5257d3ebbf73f960c73c3c"}, "meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, - "mock": {:hex, :mock, "0.3.7", "75b3bbf1466d7e486ea2052a73c6e062c6256fb429d6797999ab02fa32f29e03", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "4da49a4609e41fd99b7836945c26f373623ea968cfb6282742bcb94440cf7e5c"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"}, - "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, - "sweet_xml": {:hex, :sweet_xml, "0.7.2", "4729f997286811fabdd8288f8474e0840a76573051062f066c4b597e76f14f9f", [:mix], [], "hexpm", "6894e68a120f454534d99045ea3325f7740ea71260bc315f82e29731d570a6e8"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, - "xml_builder": {:hex, :xml_builder, "2.2.0", "cc5f1eeefcfcde6e90a9b77fb6c490a20bc1b856a7010ce6396f6da9719cbbab", [:mix], [], "hexpm", "9d66d52fb917565d358166a4314078d39ef04d552904de96f8e73f68f64a62c9"}, + "mimerl": {:hex, :mimerl, "1.5.0", "f35aca6f23242339b3666e0ac0702379e362b469d0aea167f6cc713547e777ed", [:rebar3], [], "hexpm", "db648ce065bae14ea84ca8b5dd123f42f49417cef693541110bf6f9e9be9ecc4"}, + "mock": {:hex, :mock, "0.3.9", "10e44ad1f5962480c5c9b9fa779c6c63de9bd31997c8e04a853ec990a9d841af", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "9e1b244c4ca2551bb17bb8415eed89e40ee1308e0fbaed0a4fdfe3ec8a4adbd3"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"}, + "parse_trans": {:hex, :parse_trans, "3.4.2", "c352ddc1a0d5e54f9b1654d45f9c432eef76f9cea371c55ddff769ef688fdb74", [:rebar3], [], "hexpm", "4c25347de3b7c35732d32e69ab43d1ceee0beae3f3b3ade1b59cbd3dd224d9ca"}, + "quic": {:hex, :quic, "1.6.5", "28b7d49c1732b2de3861701bb03ae7798537240552370ac49f0d139d2ea8f621", [:rebar3], [], "hexpm", "de1a88972c33201a50d1a17c8c4a14528bd1d8f25ef705897d680ae312d0aa78"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, + "sweet_xml": {:hex, :sweet_xml, "0.7.5", "803a563113981aaac202a1dbd39771562d0ad31004ddbfc9b5090bdcd5605277", [:mix], [], "hexpm", "193b28a9b12891cae351d81a0cead165ffe67df1b73fe5866d10629f4faefb12"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.1", "a48703a25c170eedadca83b11e88985af08d35f37c6f664d6dcfb106a97782fc", [:rebar3], [], "hexpm", "b3a917854ce3ae233619744ad1e0102e05673136776fb2fa76234f3e03b23642"}, + "webtransport": {:hex, :webtransport, "0.4.1", "60ef6cd99282b5964c8172d674519239e31e357d934bde028bec70da34636fe5", [:rebar3], [{:h2, "~> 0.10.1", [hex: :h2, repo: "hexpm", optional: false]}, {:quic, "~> 1.6.5", [hex: :quic, repo: "hexpm", optional: false]}], "hexpm", "006e4e52a8f03b69201d4637c85b424a4ddccc1909f32c5742fed8d495a75174"}, + "xml_builder": {:hex, :xml_builder, "2.4.0", "b20d23077266c81f593360dc037ea398461dddb6638a329743da6c73afa56725", [:mix], [], "hexpm", "833e325bb997f032b5a1b740d2fd6feed3c18ca74627f9f5f30513a9ae1a232d"}, } diff --git a/test/fixtures/xml/send_service/MarkedAsSafeRequest.xml b/test/fixtures/xml/send_service/MarkedAsSafeRequest.xml new file mode 100644 index 0000000..06ee718 --- /dev/null +++ b/test/fixtures/xml/send_service/MarkedAsSafeRequest.xml @@ -0,0 +1 @@ +TY&PE diff --git a/test/soap/request/params_test.exs b/test/soap/request/params_test.exs index 636330c..53b63fd 100644 --- a/test/soap/request/params_test.exs +++ b/test/soap/request/params_test.exs @@ -8,7 +8,7 @@ defmodule Soap.Request.ParamsTest do test "#build_body converts map to Xml-like string successful" do xml_body = Fixtures.load_xml("send_service/SendMessageRequest.xml") - parameters = %{recipient: "WSPB", body: "BODY", type: "TYPE", date: "2018-01-19"} + parameters = [body: "BODY", date: "2018-01-19", recipient: "WSPB", type: "TYPE"] {_, wsdl} = Wsdl.parse_from_file(@wsdl_path) function_result = Params.build_body(wsdl, @operation, parameters, nil) @@ -17,7 +17,7 @@ defmodule Soap.Request.ParamsTest do test "#build_body uses the custom WSDL SOAP version" do xml_body = Fixtures.load_xml("send_service/SendMessageRequest_soap12.xml") - parameters = %{recipient: "WSPB", body: "BODY", type: "TYPE", date: "2018-01-19"} + parameters = [body: "BODY", date: "2018-01-19", recipient: "WSPB", type: "TYPE"] {_, wsdl} = Wsdl.parse_from_file(@wsdl_path, soap_version: "1.2") function_result = Params.build_body(wsdl, @operation, parameters, nil) @@ -49,13 +49,27 @@ defmodule Soap.Request.ParamsTest do Fixtures.load_xml("send_service/SendMessageRequest.xml") |> String.replace("WSPB", "123") - parameters = %{recipient: "123", body: "BODY", type: "TYPE", date: "2018-01-19"} + parameters = [body: "BODY", date: "2018-01-19", recipient: "123", type: "TYPE"] {_, wsdl} = Wsdl.parse_from_file(@wsdl_path) function_result = Params.build_body(wsdl, @operation, parameters, nil) assert function_result == xml_body end + test "values can be marked as safe" do + xml_body = + Fixtures.load_xml("send_service/MarkedAsSafeRequest.xml") + |> String.replace("WSPB", "123") + + parameters = %{type: {:__safe, "TY&PE"}} + {_, wsdl} = Wsdl.parse_from_file(@wsdl_path) + # This will be an invalid XML file, but we need to test that XmlBuilder + # sends the value straight through + function_result = Params.build_body(wsdl, @operation, parameters, nil) + + assert function_result == xml_body + end + test "#build_body returns wrong date format errors" do parameters = %{"date" => "09:00:00"} {_, wsdl} = Wsdl.parse_from_file(@wsdl_path)