Skip to content

Commit

Permalink
Merge pull request #49 from agrare/strip_dot_dollar_from_credentials
Browse files Browse the repository at this point in the history
Strip trailing .$ from Credentials
  • Loading branch information
kbrock authored Sep 25, 2023
2 parents 1c60c22 + 2ffd0f3 commit 209f637
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ def run(args = {})
object = object_type.constantize.find_by(:id => object_id) if object_type && object_id
object.before_ae_starts({}) if object.present? && object.respond_to?(:before_ae_starts)

creds = credentials&.transform_values do |val|
if val.kind_of?(Hash)
creds = credentials&.to_h do |key, val|
if key.end_with?(".$")
credential_ref, credential_field = val.values_at("credential_ref", "credential_field")

authentication = parent.authentications.find_by(:ems_ref => credential_ref)
raise ActiveRecord::RecordNotFound, "Couldn't find Authentication" if authentication.nil?

authentication.send(credential_field)
[key.chomp(".$"), authentication.send(credential_field)]
else
val
[key, val]
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
end

context "with a Credentials property in the workflow_content" do
let(:credentials) { {"username" => {"credential_ref" => "my-credential", "credential_field" => "userid"}, "password" => {"credential_ref" => "my-credential", "credential_field" => "password"}} }
let(:credentials) { {"username.$" => {"credential_ref" => "my-credential", "credential_field" => "userid"}, "password.$" => {"credential_ref" => "my-credential", "credential_field" => "password"}} }
let(:payload) do
{
"Comment" => "Example Workflow",
Expand All @@ -134,8 +134,8 @@
"FirstState" => {
"Type" => "Succeed",
"Credentials" => {
"username" => "$.username",
"password" => "$.password"
"username.$" => "$.username",
"password.$" => "$.password"
}
}
}
Expand Down

0 comments on commit 209f637

Please sign in to comment.