Skip to content

Commit

Permalink
Merge pull request #111 from yast/review_160902_bug_996823_master
Browse files Browse the repository at this point in the history
[Review] Request from 'schubi2' @ 'yast/yast-users/review_160902_bug_996823_master'
  • Loading branch information
schubi2 committed Sep 2, 2016
2 parents 5861b2c + 58c76df commit 29d0c40
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 9 deletions.
7 changes: 7 additions & 0 deletions package/yast2-users.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Sep 2 15:16:37 CEST 2016 - schubi@suse.de

- AutoYaST: Ignore Users without UID while checking for duplicate
UIDs (bnc#996823)
- 3.1.57

-------------------------------------------------------------------
Tue Aug 30 10:37:18 CEST 2016 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-users.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-users
Version: 3.1.56
Version: 3.1.57
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
5 changes: 4 additions & 1 deletion src/clients/users_auto.rb
Expand Up @@ -171,7 +171,10 @@ def check_users(users)
if users.size > users.uniq { |u| u["username"]}.size
Report.Error(_("Found users in profile with equal <username>."))
end
if users.size > users.uniq { |u| u["uid"]}.size
# Do not check users without defined UID. (bnc#996823)
check_users = users.dup
check_users.reject! { |u| !u.key?("uid")}
if check_users.size > check_users.uniq { |u| u["uid"]}.size
Report.Error(_("Found users in profile with equal <uid>."))
end
end
Expand Down
29 changes: 29 additions & 0 deletions test/fixtures/users_no_error.yml
@@ -0,0 +1,29 @@
users:
- username: root
user_password: yast.password
fullname: Superuser
encrypted: true
- username: yast
user_password: suse
fullname: YaST team user
gid: 100
uid: 1000
shell: /usr/bin/zsh
encrypted: true
- username: saprouter
user_password: suse
fullname: SAP User
gid: 100
uid: 1001
shell: /usr/bin/zsh
encrypted: true
- username: user_no_uid1
user_password: suse
fullname: user_no_uid1
shell: /usr/bin/zsh
encrypted: true
- username: user_no_uid2
user_password: suse
fullname: user_no_uid2
shell: /usr/bin/zsh
encrypted: true
21 changes: 14 additions & 7 deletions test/users_auto_test.rb
Expand Up @@ -19,23 +19,30 @@
describe "#AutoYaST" do

context "Import" do
before do
allow(Yast::WFM).to receive(:Args).with(no_args).and_return([func,users])
allow(Yast::WFM).to receive(:Args).with(0).and_return(func)
allow(Yast::WFM).to receive(:Args).with(1).and_return(users)
end

let(:func) { "Import" }

context "when double users have been given in the profile" do
let(:users) { YAML.load_file(FIXTURES_PATH.join("users_error.yml")) }

before do
allow(Yast::WFM).to receive(:Args).with(no_args).and_return([func,users])
allow(Yast::WFM).to receive(:Args).with(0).and_return(func)
allow(Yast::WFM).to receive(:Args).with(1).and_return(users)
end

it "report error" do
expect(Yast::Report).to receive(:Error).with(_("Found users in profile with equal <username>."))
expect(Yast::Report).to receive(:Error).with(_("Found users in profile with equal <uid>."))
expect(subject.main).to eq(true)
end
end
context "when users without any UID are defined in the profile" do
let(:users) { YAML.load_file(FIXTURES_PATH.join("users_no_error.yml")) }
it "will not be checked for double UIDs" do
expect(Yast::Report).not_to receive(:Error).with(_("Found users in profile with equal <username>."))
expect(Yast::Report).not_to receive(:Error).with(_("Found users in profile with equal <uid>."))
expect(subject.main).to eq(true)
end
end
end
end
end

0 comments on commit 29d0c40

Please sign in to comment.