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

yast / yast-users / 16077555618

04 Jul 2025 04:09PM UTC coverage: 70.346% (+10.0%) from 60.368%
16077555618

push

github

web-flow
Merge pull request #402 from yast/disable-auto-client-tests

Disable auto client unit tests

3212 of 4566 relevant lines covered (70.35%)

40.81 hits per line

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

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

20
require "yast"
1✔
21
require "y2users/users_module/reader"
1✔
22
require "y2users/users_module/commit_config_reader"
1✔
23
require "y2users/linux/useradd_config_reader"
1✔
24
require "y2users/linux/writer"
1✔
25
require "y2issues"
1✔
26

27
module Yast
1✔
28
  # Module to make possible for Yast::Users to use some of the Y2Users::Linux components, like
29
  # the {Y2Users::Linux::Writer} and the {Y2Users::Linux::UseraddConfigReader}
30
  class Y2UsersLinuxClass < Module
1✔
31
    include Yast::Logger
1✔
32

33
    # Mapping from {Y2Users::UseraddConfig} attributes into names of the keys used in the
34
    # {Yast::Users} hashes
35
    EXPORTED_USERADD_ATTRS = {
36
      group:             "group",
1✔
37
      home:              "home",
38
      shell:             "shell",
39
      skel:              "skel",
40
      umask:             "umask",
41
      inactivity_period: "inactive",
42
      expiration:        "expire"
43
    }
44
    private_constant :EXPORTED_USERADD_ATTRS
1✔
45

46
    # Reads the defaults for useradd
47
    #
48
    # These values are used by {Yast::Users} for initializing the UI fields
49
    #
50
    # @return [Hash<String, String>] A hash with the structure (ie. keys) used by {Yast::Users} to
51
    #   handle, receive and return the useradd defaults
52
    def read_useradd_config
1✔
53
      useradd_config = Y2Users::Linux::UseraddConfigReader.new.read
×
54

55
      EXPORTED_USERADD_ATTRS.each_with_object({}) do |(attr, key), result|
×
56
        result[key] = useradd_config.public_send(attr) || ""
×
57
      end
58
    end
59

60
    # Persists the changes from {Yast::Users} to the system
61
    #
62
    # @return [Array<String>] errors triggered during the write process, empty array if everything
63
    #   went fine
64
    def write_from_users_module
1✔
65
      system_config, target_config = Y2Users::UsersModule::Reader.new.read
×
66
      commit_configs = Y2Users::UsersModule::CommitConfigReader.new.read
×
67
      writer = Y2Users::Linux::Writer.new(target_config, system_config, commit_configs)
×
68

69
      issues = writer.write
×
70
      log_errors(issues)
×
71

72
      issues.map(&:message)
×
73
    end
74

75
    publish function: :read_useradd_config, type: "map ()"
1✔
76
    publish function: :write_from_users_module, type: "list <string> ()"
1✔
77

78
  private
1✔
79

80
    # Writes the given list of issues to the YaST logs if needed
81
    def log_errors(issues)
1✔
82
      return if issues.empty?
×
83

84
      presenter = Y2Issues::Presenter.new(issues)
×
85
      log.error("Errors found calling Y2Users::Linux::Writer: #{presenter.to_plain}")
×
86
    end
87
  end
88

89
  Y2UsersLinux = Y2UsersLinuxClass.new
1✔
90
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

© 2025 Coveralls, Inc