• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-users / 5453098972

pending completion
5453098972

Pull #383

github

web-flow
Merge 54d62cefa into f91b954c3
Pull Request #383: User creation page got messed when going back after importing user(s) from existing installation

16 of 16 new or added lines in 1 file covered. (100.0%)

3319 of 5513 relevant lines covered (60.2%)

35.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.47
/src/include/users/wizards.rb
1
# encoding: utf-8
2

3
# ------------------------------------------------------------------------------
4
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
5
#
6
#
7
# This program is free software; you can redistribute it and/or modify it under
8
# the terms of version 2 of the GNU General Public License as published by the
9
# Free Software Foundation.
10
#
11
# This program is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along with
16
# this program; if not, contact Novell, Inc.
17
#
18
# To contact Novell about this file by physical or electronic mail, you may find
19
# current contact information at www.novell.com.
20
# ------------------------------------------------------------------------------
21

22
# File:        include/users/wizards.ycp
23
# Package:        Configuration of users and groups
24
# Summary:        Wizards definitions
25
# Authors:        Johannes Buchhold <jbuch@suse.de>,
26
#          Jiri Suchomel <jsuchome@suse.cz>
27
#
28
# $Id$
29
module Yast
1✔
30
  module UsersWizardsInclude
1✔
31
    def initialize_users_wizards(include_target)
1✔
32
      Yast.import "UI"
18✔
33

34
      textdomain "users"
18✔
35

36
      Yast.import "CWM"
18✔
37
      Yast.import "CWMTab"
18✔
38
      Yast.import "Label"
18✔
39
      Yast.import "Ldap"
18✔
40
      Yast.import "Mode"
18✔
41
      Yast.import "Popup"
18✔
42
      Yast.import "Sequencer"
18✔
43
      Yast.import "Stage"
18✔
44
      Yast.import "UsersCache"
18✔
45
      Yast.import "Users"
18✔
46
      Yast.import "Wizard"
18✔
47

48
      Yast.include include_target, "users/complex.rb"
18✔
49
      Yast.include include_target, "users/dialogs.rb"
18✔
50
      Yast.include include_target, "users/widgets.rb"
18✔
51
    end
52

53
    # ------------------ CWM ---------------------------------------------------
54
    # --------------------------------------------------------------------------
55

56
    def ReallyBack
1✔
57
      if !Stage.cont && Users.Modified
×
58
        return Popup.ReallyAbort(Users.Modified)
×
59
      else
60
        return true
×
61
      end
62
    end
63

64
    # Before showing the table for first time,
65
    # read LDAP/NIS if they are included in custom set
66
    def InitializeTableItems
1✔
67
      if UsersCache.CustomizedUsersView || UsersCache.CustomizedGroupsView
×
68
        if (Builtins.contains(Users.GetUserCustomSets, "ldap") ||
×
69
            Builtins.contains(Users.GetGroupCustomSets, "ldap")) &&
70
            Ldap.bind_pass == nil
71
          Ldap.SetBindPassword(Ldap.GetLDAPPassword(true))
×
72
        end
73
        Users.ChangeCurrentUsers("custom") if UsersCache.CustomizedUsersView
×
74
        Users.ChangeCurrentGroups("custom") if UsersCache.CustomizedGroupsView
×
75
      end
76
      :next
×
77
    end
78

79
    # run the main (Summary) dialog via CWM
80
    def SummaryDialog
1✔
81
      Ops.set(
×
82
        @widgets,
83
        "tab_users_groups",
84
        CWMTab.CreateWidget(
85
          {
86
            "tab_order"    => ["users", "groups", "defaults", "authentication"],
87
            "tabs"         => @tabs_description,
88
            "widget_descr" => @widgets,
89
            "initial_tab"  => UsersCache.GetCurrentSummary
90
          }
91
        )
92
      )
93

94
      contents = VBox("tab_users_groups")
×
95

96
      ret = CWM.ShowAndRun(
×
97
        {
98
          "widget_names"       => ["tab_users_groups"],
99
          "widget_descr"       => @widgets,
100
          "contents"           => contents,
101
          # dialog caption
102
          "caption"            => _(
103
            "User and Group Administration"
104
          ),
105
          "back_button"        => Stage.cont ? Label.BackButton : "",
×
106
          "next_button"        => Stage.cont ? Label.NextButton : Label.OKButton,
×
107
          "abort_button"       => Stage.cont ? Label.AbortButton : Label.CancelButton,
×
108
          "fallback_functions" => {
109
            :back => fun_ref(method(:ReallyBack), "boolean ()")
110
          }
111
        }
112
      )
113
      if ret != nil && Ops.is_symbol?(ret) &&
×
114
          Builtins.contains([:new, :edit, :delete], Convert.to_symbol(ret))
115
        update_symbol = {
116
          :new    => { "users" => :new_user, "groups" => :new_group },
×
117
          :edit   => { "users" => :edit_user, "groups" => :edit_group },
118
          :delete => { "users" => :delete_user, "groups" => :delete_group }
119
        }
120
        ret = Ops.get_symbol(
×
121
          update_symbol,
122
          [ret, UsersCache.GetCurrentSummary],
123
          :back
124
        )
125
      end
126

127
      if Stage.cont && (ret == :back || ret == :abort)
×
128
        Users.SetStartDialog("user_add")
×
129
        Users.SetUseNextTime(true)
×
130
        old_gui = Users.GetGUI
×
131
        Users.SetGUI(false)
×
132
        Users.Read
×
133
        # read also LDAP again: bug #41299
134
        current_users = Users.GetCurrentUsers
×
135
        if Builtins.contains(current_users, "ldap")
×
136
          Users.SetLDAPNotRead(true)
×
137
          Users.ChangeCurrentUsers("ldap")
×
138
        else
139
          # update the user item list
140
          Users.ChangeCurrentUsers("custom")
×
141
        end
142
        Users.SetGUI(old_gui)
×
143
        ret = :back
×
144
      end
145

146
      Convert.to_symbol(ret)
×
147
    end
148

149

150
    # --------------------------------------------------------------------------
151
    # --------------------------------------------------------------------------
152

153

154
    # Main workflow of the users/groups configuration
155
    # @param [String] start the first dialog
156
    # @return sequence result
157
    def MainSequence(start)
1✔
158
      aliases = {
159
        "init_summary"    => [lambda { InitializeTableItems() }, true],
×
160
        "summary"         => lambda { SummaryDialog() },
×
161
        "user_add"        => lambda { EditUserDialog("add_user") },
×
162
        "user_add_inst"   => lambda { EditUserDialog("add_user") },
×
163
        "user_inst_start" => [lambda { usersInstStart }, true],
×
164
        "user_edit"       => lambda { EditUserDialog("edit_user") },
×
165
        "user_save"       => [lambda { UserSave() }, true],
×
166
        "group_add"       => lambda { EditGroupDialog("add_group") },
×
167
        "group_edit"      => lambda { EditGroupDialog("edit_group") },
×
168
        "group_save"      => [lambda { GroupSave() }, true],
×
169
        "without_save"    => lambda { ReallyAbort() }
×
170
      }
171

172
      main_sequence = {
173
        "ws_start"        => "init_summary",
×
174
        "init_summary"    => { :next => start },
175
        "summary"         => {
176
          :new_user     => "user_add",
177
          :edit_user    => "user_edit",
178
          :delete_user  => "user_save",
179
          :new_group    => "group_add",
180
          :edit_group   => "group_edit",
181
          :delete_group => "group_save",
182
          :abort        => "without_save",
183
          :cancel       => "without_save",
184
          :next         => :next,
185
          :ok           => :next,
186
          :nosave       => :nosave,
187
          :exit         => :abort,
188
          :summary      => "summary"
189
        },
190
        "user_add"        => {
191
          :nextmodule => :next,
192
          :nosave     => "summary",
193
          :additional => "user_save",
194
          # only install
195
          :next       => "user_save",
196
          # -> Commit
197
          :abort      => :abort,
198
          :cancel     => :abort
199
        },
200
        "user_add_inst"   => {
201
          :nextmodule => :next,
202
          # no user and next pressed (install)
203
          :nosave     => "summary",
204
          :additional => "user_save",
205
          :next       => "user_save",
206
          :abort      => "without_save",
207
          :cancel     => "without_save"
208
        },
209
        "user_edit"       => {
210
          :next   => "user_save",
211
          :abort  => :abort,
212
          :cancel => :abort
213
        },
214
        "user_inst_start" => { :next => "user_add_inst" },
215
        "user_save" =>
216
          #this should be write - during install??
217
          { :next => "summary", :save => :next },
218
        "group_add"       => {
219
          :nosave => "summary",
220
          :next   => "group_save",
221
          :abort  => :abort,
222
          :cancel => :abort
223
        },
224
        "group_edit"      => {
225
          :next   => "group_save",
226
          :abort  => :abort,
227
          :cancel => :abort
228
        },
229
        "group_save"      => { :next => "summary" },
230
        "without_save"    => {
231
          :next  => :next,
232
          :abort => :abort,
233
          :back  => :back
234
        }
235
      }
236

237
      Sequencer.Run(aliases, main_sequence)
×
238
    end
239

240
    # Whole configuration of users/groups
241
    # @param [String] start the first dialog
242
    # @return sequence result
243
    def UsersSequence(start)
1✔
244
      aliases = {
245
        "read"  => [lambda { ReadDialog(!Stage.cont) }, true],
×
246
        "main"  => lambda { MainSequence(start) },
×
247
        "write" => [lambda { WriteDialog(true) }, true]
×
248
      } # true as parameter ??
249

250
      sequence = {
251
        "ws_start" => "read",
×
252
        "read" =>
253
          # this is for skiping users conf during install,
254
          # see Users::CheckHomeMounted() or bug #20365
255
          { :abort => :abort, :next => "main", :nextmodule => :next },
256
        "main"     => { :abort => :abort, :next => "write", :nosave => :next },
257
        "write"    => { :abort => :abort, :next => :next }
258
      }
259

260
      # init dialog caption
261
      caption = _("User and Group Configuration")
×
262
      # label (during init dialog)
263
      contents = Label(_("Initializing..."))
×
264

265
      Wizard.OpenNextBackDialog if !Stage.cont
×
266
      Wizard.SetDesktopIcon("org.opensuse.yast.Users")
×
267

268
      ret = Sequencer.Run(aliases, sequence)
×
269

270
      UI.CloseDialog if !Stage.cont
×
271

272
      # read LDAP again in the next run
273
      Users.SetLDAPNotRead(true)
×
274

275
      Convert.to_symbol(ret)
×
276
    end
277

278
    # Whole configuration of users/groups but without reading and writing.
279
    # For use with autoinstallation.
280
    # @param [String] start the first dialog
281
    # @return sequence result
282
    def AutoSequence(start)
1✔
283
      # dialog caption
284
      caption = _("User and Group Configuration")
×
285

286
      # label (during init dialog)
287
      contents = Label(_("Initializing..."))
×
288

289
      Wizard.CreateDialog
×
290
      Wizard.SetDesktopIcon("org.opensuse.yast.Users")
×
291
      Wizard.SetContentsButtons(
×
292
        caption,
293
        contents,
294
        "",
295
        Label.BackButton,
296
        Label.NextButton
297
      )
298

299
      # initialization: ---------------- (simulate empty Import: bug #44660)
300
      Users.Initialize if Mode.config && !Users.Modified
×
301
      # --------------------------------
302

303
      ret = MainSequence(start)
×
304

305
      UI.CloseDialog
×
306
      ret
×
307
    end
308
  end
309
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc