Skip to content

Commit

Permalink
specs for changing default user/pass
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorerlingsson committed Feb 21, 2025
1 parent c5f18bd commit c1c6c53
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/users_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,35 @@ describe LavinMQ::Server do
end
end
end

it "allows changing default user" do
LavinMQ::Config.instance.default_user = "spec"
LavinMQ::Config.instance.default_password = "spec"
with_amqp_server do |s|
with_channel(s, user: "spec", password: "spec") { }
end
end

it "allows changing default user with env variables" do
ENV["LAVINMQ_DEFAULT_USER"] = "spec"
ENV["LAVINMQ_DEFAULT_PASSWORD"] = "spec"
with_amqp_server do |s|
with_channel(s, user: "spec", password: "spec") { }
end
ensure
ENV.delete("LAVINMQ_DEFAULT_USER")
ENV.delete("LAVINMQ_DEFAULT_PASSWORD")
end

it "disallows 'guest' if default user is changed" do
LavinMQ::Config.instance.default_user = "spec"
LavinMQ::Config.instance.default_password = "spec"
with_amqp_server do |s|
expect_raises(AMQP::Client::Connection::ClosedException) do
with_channel(s, user: "guest", password: "guest") { }
end
end
end
end

describe LavinMQ::Tag do
Expand Down

0 comments on commit c1c6c53

Please sign in to comment.