Skip to content

Commit

Permalink
Fix flaky auth_token spec caused by time zone sensitivity
Browse files Browse the repository at this point in the history
The `RDS::AuthTokenGenerator` spec was written in a way that assumed
the system clock is always UTC. This meant that the spec would always
pass in CI, since the GitHub Actions runner uses UTC, but sometimes fail
when running locally.

Specifically, after 4pm PST, the local date and UTC dates are different,
leading to a mismatch in the expected and actual date.

This commit explicitly converts the date to UTC with `.utc` so that the
spec now consistently passes regardless of local time zone.
  • Loading branch information
mattbrictson committed Nov 20, 2023
1 parent e0115af commit a1a3e30
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gems/aws-sdk-rds/spec/auth_token_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module RDS
)
expect(token).to match(/#{endpoint}\/\?Action=connect/)
expect(token).to match(/DBUser=#{user_name}/)
expect(token).to match(/X-Amz-Credential=akid%2F#{now.strftime('%Y%m%d')}%2F#{region}%2Frds-db%2Faws4_request/)
expect(token).to match(/X-Amz-Credential=akid%2F#{now.utc.strftime('%Y%m%d')}%2F#{region}%2Frds-db%2Faws4_request/)
end

end
Expand Down

0 comments on commit a1a3e30

Please sign in to comment.