Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Nov 14, 2024
1 parent 37e5b91 commit 27f19f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions service/test/agama/dbus/users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
let(:user) { nil }

it "returns default data" do
expect(subject.first_user).to eq(["", "", "", false, {}])
expect(subject.first_user).to eq(["", "", "", false, false, {}])
end
end

Expand All @@ -86,7 +86,7 @@
end

it "returns the first user data" do
expect(subject.first_user).to eq(["Test user", "test", "12345", true, {}])
expect(subject.first_user).to eq(["Test user", "test", "12345", false, true, {}])
end
end
end
Expand Down
18 changes: 9 additions & 9 deletions service/test/agama/users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@
describe "#assign_first_user" do
context "when the options given do not present any issue" do
it "adds the user to the user's configuration" do
subject.assign_first_user("Jane Doe", "jane", "12345", false, {})
subject.assign_first_user("Jane Doe", "jane", "12345", false, false, {})
user = users_config.users.by_name("jane")
expect(user.full_name).to eq("Jane Doe")
expect(user.password).to eq(Y2Users::Password.create_plain("12345"))
end

context "when a first user exists" do
before do
subject.assign_first_user("Jane Doe", "jane", "12345", false, {})
subject.assign_first_user("Jane Doe", "jane", "12345", false, false, {})
end

it "replaces the user with the new one" do
subject.assign_first_user("John Doe", "john", "12345", false, {})
subject.assign_first_user("John Doe", "john", "12345", false, false, {})

user = users_config.users.by_name("jane")
expect(user).to be_nil
Expand All @@ -104,31 +104,31 @@
end

it "returns an empty array of issues" do
issues = subject.assign_first_user("Jane Doe", "jane", "12345", false, {})
issues = subject.assign_first_user("Jane Doe", "jane", "12345", false, false, {})
expect(issues).to be_empty
end
end

context "when the given arguments presents some critical error" do
it "does not add the user to the config" do
subject.assign_first_user("Jonh Doe", "john", "", false, {})
subject.assign_first_user("Jonh Doe", "john", "", false, false, {})
user = users_config.users.by_name("john")
expect(user).to be_nil
subject.assign_first_user("Ldap user", "ldap", "12345", false, {})
subject.assign_first_user("Ldap user", "ldap", "12345", false, false, {})
user = users_config.users.by_name("ldap")
expect(user).to be_nil
end

it "returns an array with all the issues" do
issues = subject.assign_first_user("Root user", "root", "12345", false, {})
issues = subject.assign_first_user("Root user", "root", "12345", false, false, {})
expect(issues.size).to eql(1)
end
end
end

describe "#remove_first_user" do
before do
subject.assign_first_user("Jane Doe", "jane", "12345", false, {})
subject.assign_first_user("Jane Doe", "jane", "12345", false, false, {})
end

it "removes the already defined first user" do
Expand Down Expand Up @@ -196,7 +196,7 @@

context "when a first user is defined" do
before do
subject.assign_first_user("Jane Doe", "jdoe", "123456", false, {})
subject.assign_first_user("Jane Doe", "jdoe", "123456", false, false, {})
end

it "returns an empty list" do
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/users/RootPasswordPopup.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ describe("when it is open", () => {
expect(confirmButton).toBeEnabled();
await user.click(confirmButton);

expect(mockRootUserMutation.mutateAsync).toHaveBeenCalledWith({ password });
expect(mockRootUserMutation.mutateAsync).toHaveBeenCalledWith({
password,
passwordEncrypted: false,
});
expect(onCloseCallback).toHaveBeenCalled();
});

Expand Down

0 comments on commit 27f19f6

Please sign in to comment.