kanrisuru 0.4.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +13 -0
  3. data/CHANGELOG.md +84 -0
  4. data/README.md +3 -0
  5. data/lib/kanrisuru/core.rb +6 -0
  6. data/lib/kanrisuru/core/apt.rb +6 -6
  7. data/lib/kanrisuru/core/dmi.rb +533 -0
  8. data/lib/kanrisuru/core/socket.rb +16 -16
  9. data/lib/kanrisuru/core/system.rb +84 -0
  10. data/lib/kanrisuru/core/yum.rb +8 -8
  11. data/lib/kanrisuru/core/zypper.rb +1094 -0
  12. data/lib/kanrisuru/remote/fstab.rb +3 -3
  13. data/lib/kanrisuru/util.rb +1 -0
  14. data/lib/kanrisuru/util/bits.rb +3 -3
  15. data/lib/kanrisuru/util/dmi_type.rb +1366 -0
  16. data/lib/kanrisuru/version.rb +1 -1
  17. data/spec/functional/core/apt_spec.rb +97 -158
  18. data/spec/functional/core/dmi_spec.rb +37 -0
  19. data/spec/functional/core/file_spec.rb +5 -12
  20. data/spec/functional/core/system_spec.rb +21 -0
  21. data/spec/functional/core/yum_spec.rb +38 -80
  22. data/spec/functional/core/zypper_spec.rb +193 -0
  23. data/spec/functional/remote/fstab_spec.rb +1 -1
  24. data/spec/helper/test_hosts.rb +7 -1
  25. data/spec/unit/core/apt_spec.rb +42 -0
  26. data/spec/unit/core/archive_spec.rb +11 -0
  27. data/spec/unit/core/disk_spec.rb +21 -0
  28. data/spec/unit/core/dmi_spec.rb +271 -0
  29. data/spec/unit/core/file_spec.rb +9 -0
  30. data/spec/unit/core/find_spec.rb +9 -0
  31. data/spec/unit/core/group_spec.rb +10 -0
  32. data/spec/unit/core/ip_spec.rb +59 -0
  33. data/spec/unit/core/path_spec.rb +16 -0
  34. data/spec/unit/core/socket_spec.rb +38 -0
  35. data/spec/unit/core/stat_spec.rb +14 -0
  36. data/spec/unit/core/system_spec.rb +79 -0
  37. data/spec/unit/core/transfer_spec.rb +15 -0
  38. data/spec/unit/core/user_spec.rb +11 -0
  39. data/spec/unit/core/yum_spec.rb +47 -0
  40. data/spec/unit/core/zypper_spec.rb +121 -0
  41. data/spec/unit/util_spec.rb +224 -0
  42. metadata +23 -2
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::File do
6
+ it 'responds to file fields' do
7
+ expect(Kanrisuru::Core::File::FileCount.new).to respond_to(:lines, :words, :characters)
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Find do
6
+ it 'responds to find fields' do
7
+ expect(Kanrisuru::Core::Find::FilePath.new).to respond_to(:path)
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Group do
6
+ it 'responds to group fields' do
7
+ expect(Kanrisuru::Core::Group::Group.new).to respond_to(:gid, :name, :users)
8
+ expect(Kanrisuru::Core::Group::GroupUser.new).to respond_to(:uid, :name)
9
+ end
10
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::IP do
6
+ it 'responds to ip fields' do
7
+ expect(Kanrisuru::Core::IP::IPROUTE2_JSON_VERSION).to(
8
+ eq(180_129)
9
+ )
10
+
11
+ expect(Kanrisuru::Core::IP::IP_ROUTE_TYPES).to(
12
+ eq(%w[
13
+ unicast unreachable blackhole prohibit local
14
+ broadcast throw nat via anycast multicast
15
+ ])
16
+ )
17
+
18
+ expect(Kanrisuru::Core::IP::IPLinkProperty.new).to respond_to(
19
+ :index, :name, :flags, :mtu,
20
+ :qdisc, :state, :group, :qlen,
21
+ :link_mode, :link_type, :mac_address, :alias,
22
+ :stats
23
+ )
24
+ expect(Kanrisuru::Core::IP::IPAddressProperty.new).to respond_to(
25
+ :index, :name, :flags, :mtu,
26
+ :qdisc, :state, :group, :qlen,
27
+ :link_type, :mac_address,
28
+ :address_info, :stats
29
+ )
30
+ expect(Kanrisuru::Core::IP::IPAddressInfo.new).to respond_to(
31
+ :family, :ip, :broadcast, :scope,
32
+ :dynamic, :valid_life_time, :preferred_life_time
33
+ )
34
+ expect(Kanrisuru::Core::IP::IPAddressLabel.new).to respond_to(
35
+ :address, :prefix_length, :label
36
+ )
37
+ expect(Kanrisuru::Core::IP::IPRoute.new).to respond_to(
38
+ :destination, :gateway, :device, :protocol, :scope, :preferred_source, :metric, :flags
39
+ )
40
+ expect(Kanrisuru::Core::IP::IPRule.new).to respond_to(:priority, :source, :table)
41
+ expect(Kanrisuru::Core::IP::IPNeighbour.new).to respond_to(
42
+ :destination, :device, :lladdr, :state, :stats
43
+ )
44
+ expect(Kanrisuru::Core::IP::IPNeighbourStats.new).to respond_to(
45
+ :used, :confirmed, :updated, :probes, :ref_count
46
+ )
47
+ expect(Kanrisuru::Core::IP::IPMAddress.new).to respond_to(:index, :name, :maddr)
48
+ expect(Kanrisuru::Core::IP::IPMAddressEntry.new).to respond_to(
49
+ :family, :link, :address, :users
50
+ )
51
+ expect(Kanrisuru::Core::IP::IPStats.new).to respond_to(:rx, :tx)
52
+ expect(Kanrisuru::Core::IP::IPStatRX.new).to respond_to(
53
+ :bytes, :packets, :errors, :dropped, :over_errors, :multicast
54
+ )
55
+ expect(Kanrisuru::Core::IP::IPStatTX.new).to respond_to(
56
+ :bytes, :packets, :errors, :dropped, :carrier_errors, :collisions
57
+ )
58
+ end
59
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Path do
6
+ it 'responds to path fields' do
7
+ expect(Kanrisuru::Core::Path::FilePath.new).to respond_to(:path)
8
+ expect(Kanrisuru::Core::Path::FileInfoId.new).to respond_to(
9
+ :inode, :mode, :memory_blocks, :uid, :gid, :fsize, :date, :path, :type
10
+ )
11
+ expect(Kanrisuru::Core::Path::FileInfo.new).to respond_to(
12
+ :inode, :mode, :memory_blocks, :owner, :group, :fsize, :date, :path, :type
13
+ )
14
+ expect(Kanrisuru::Core::Path::UserName.new).to respond_to(:user)
15
+ end
16
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Socket do
6
+ it 'responds to socket fields' do
7
+ expect(Kanrisuru::Core::Socket::Statistics.new).to respond_to(
8
+ :netid, :state, :receive_queue, :send_queue,
9
+ :local_address, :local_port, :peer_address, :peer_port,
10
+ :memory
11
+ )
12
+ expect(Kanrisuru::Core::Socket::StatisticsMemory.new).to respond_to(
13
+ :rmem_alloc, :rcv_buf, :wmem_alloc, :snd_buf,
14
+ :fwd_alloc, :wmem_queued, :ropt_mem, :back_log, :sock_drop
15
+ )
16
+ expect(Kanrisuru::Core::Socket::TCP_STATES).to eq(
17
+ %w[
18
+ established syn-sent syn-recv
19
+ fin-wait-1 fin-wait-2 time-wait
20
+ closed close-wait last-ack listening closing
21
+ ]
22
+ )
23
+ expect(Kanrisuru::Core::Socket::OTHER_STATES).to eq(
24
+ %w[
25
+ all connected synchronized bucket syn-recv
26
+ big
27
+ ]
28
+ )
29
+ expect(Kanrisuru::Core::Socket::TCP_STATE_ABBR).to eq(
30
+ {
31
+ 'ESTAB' => 'established', 'LISTEN' => 'listening', 'UNCONN' => 'unconnected',
32
+ 'SYN-SENT' => 'syn-sent', 'SYN-RECV' => 'syn-recv', 'FIN-WAIT-1' => 'fin-wait-1',
33
+ 'FIN-WAIT-2' => 'fin-wait-2', 'TIME-WAIT' => 'time-wait', 'CLOSE-WAIT' => 'close-wait',
34
+ 'LAST-ACK' => 'last-ack', 'CLOSING' => 'closing'
35
+ }
36
+ )
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Stat do
6
+ it 'responds to stat fields' do
7
+ expect(Kanrisuru::Core::Stat::FileStat.new).to respond_to(
8
+ :mode, :blocks, :device, :file_type,
9
+ :gid, :group, :links, :inode,
10
+ :path, :fsize, :uid, :user,
11
+ :last_access, :last_modified, :last_changed
12
+ )
13
+ end
14
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::System do
6
+ it 'responds to system fields' do
7
+ expect(Kanrisuru::Core::System::CPUArchitectureVulnerability.new).to respond_to(
8
+ :name,
9
+ :data
10
+ )
11
+ expect(Kanrisuru::Core::System::CPUArchitecture.new).to respond_to(
12
+ :architecture,
13
+ :cores,
14
+ :byte_order,
15
+ :address_sizes,
16
+ :operation_modes,
17
+ :online_cpus,
18
+ :threads_per_core,
19
+ :cores_per_socket,
20
+ :sockets,
21
+ :numa_mode,
22
+ :vendor_id,
23
+ :cpu_family,
24
+ :model,
25
+ :model_name,
26
+ :stepping,
27
+ :cpu_mhz,
28
+ :cpu_max_mhz,
29
+ :cpu_min_mhz,
30
+ :bogo_mips,
31
+ :virtualization,
32
+ :hypervisor_vendor,
33
+ :virtualization_type,
34
+ :l1d_cache,
35
+ :l1i_cache,
36
+ :l2_cache,
37
+ :l3_cache,
38
+ :numa_nodes,
39
+ :vulnerabilities,
40
+ :flags
41
+ )
42
+ expect(Kanrisuru::Core::System::KernelStatisticCpu.new).to respond_to(
43
+ :user,
44
+ :nice,
45
+ :system,
46
+ :idle,
47
+ :iowait,
48
+ :irq,
49
+ :softirq,
50
+ :steal,
51
+ :guest,
52
+ :guest_nice
53
+ )
54
+ expect(Kanrisuru::Core::System::KernelStatistic.new).to respond_to(
55
+ :cpu_total,
56
+ :cpus,
57
+ :interrupt_total,
58
+ :interrupts,
59
+ :ctxt,
60
+ :btime,
61
+ :processes,
62
+ :procs_running,
63
+ :procs_blocked,
64
+ :softirq_total,
65
+ :softirqs
66
+ )
67
+ expect(Kanrisuru::Core::System::ProcessInfo.new).to respond_to(
68
+ :uid, :user, :gid, :group, :ppid, :pid,
69
+ :cpu_usage, :memory_usage, :stat, :priority,
70
+ :flags, :policy_abbr, :policy, :cpu_time, :command
71
+ )
72
+ expect(Kanrisuru::Core::System::Uptime.new).to respond_to(
73
+ :boot_time, :uptime, :seconds, :minutes, :hours, :days
74
+ )
75
+ expect(Kanrisuru::Core::System::UserLoggedIn.new).to respond_to(
76
+ :user, :tty, :ip, :login, :idle, :jcpu, :pcpu, :command
77
+ )
78
+ end
79
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Transfer do
6
+ it 'responds to transfer fields' do
7
+ expect(Kanrisuru::Core::Transfer::WGET_FILENAME_MODES).to eq(
8
+ %w[unix windows nocontrol ascii lowercase uppercase]
9
+ )
10
+
11
+ expect(Kanrisuru::Core::Transfer::WGET_SSL_PROTO).to eq(
12
+ %w[auto SSLv2 SSLv3 TLSv1]
13
+ )
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::User do
6
+ it 'responds to user fields' do
7
+ expect(Kanrisuru::Core::User::User.new).to respond_to(:uid, :name, :home, :shell, :groups)
8
+ expect(Kanrisuru::Core::User::UserGroup.new).to respond_to(:gid, :name)
9
+ expect(Kanrisuru::Core::User::FilePath.new).to respond_to(:path)
10
+ end
11
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Yum do
6
+ it 'responds to yum fields' do
7
+ expect(Kanrisuru::Core::Yum::PackageOverview.new).to respond_to(
8
+ :package, :architecture, :version, :installed
9
+ )
10
+
11
+ expect(Kanrisuru::Core::Yum::PackageSearchResult.new).to respond_to(
12
+ :package, :architecture, :summary
13
+ )
14
+
15
+ expect(Kanrisuru::Core::Yum::PackageDetail.new).to respond_to(
16
+ :package,
17
+ :version,
18
+ :release,
19
+ :architecture,
20
+ :install_size,
21
+ :source,
22
+ :yum_id,
23
+ :repository,
24
+ :summary,
25
+ :url,
26
+ :license,
27
+ :description
28
+ )
29
+
30
+ expect(Kanrisuru::Core::Yum::Repolist.new).to respond_to(
31
+ :id,
32
+ :name,
33
+ :status,
34
+ :revision,
35
+ :packages,
36
+ :available_packages,
37
+ :repo_size,
38
+ :mirrors,
39
+ :metalink,
40
+ :updated,
41
+ :baseurl,
42
+ :expire,
43
+ :filters,
44
+ :filename
45
+ )
46
+ end
47
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Zypper do
6
+ it 'responds to zypper fields' do
7
+ expect(Kanrisuru::Core::Zypper::PACKAGE_TYPES).to(
8
+ eq(%w[package patch pattern product srcpackage application])
9
+ )
10
+
11
+ expect(Kanrisuru::Core::Zypper::PATCH_CATEGORIES).to(
12
+ eq(%w[security recommended optional feature document yast])
13
+ )
14
+
15
+ expect(Kanrisuru::Core::Zypper::PATCH_SEVERITIES).to(
16
+ eq(%w[critical important moderate low unspecified])
17
+ )
18
+
19
+ expect(Kanrisuru::Core::Zypper::SOLVER_FOCUS_MODES).to(
20
+ eq(%w[job installed update])
21
+ )
22
+
23
+ expect(Kanrisuru::Core::Zypper::MEDIUM_TYPES).to(
24
+ eq(%w[dir file cd dvd nfs iso http https ftp cifs smb hd])
25
+ )
26
+
27
+ expect(Kanrisuru::Core::Zypper::EXIT_INF_UPDATE_NEEDED).to(
28
+ eq(100)
29
+ )
30
+
31
+ expect(Kanrisuru::Core::Zypper::EXIT_INF_SEC_UPDATE_NEEDED).to(
32
+ eq(101)
33
+ )
34
+
35
+ expect(Kanrisuru::Core::Zypper::EXIT_INF_REBOOT_NEEDED).to(
36
+ eq(102)
37
+ )
38
+
39
+ expect(Kanrisuru::Core::Zypper::EXIT_INF_RESTART_NEEDED).to(
40
+ eq(103)
41
+ )
42
+
43
+ expect(Kanrisuru::Core::Zypper::EXIT_INF_CAP_NOT_FOUND).to(
44
+ eq(104)
45
+ )
46
+
47
+ expect(Kanrisuru::Core::Zypper::Repo.new).to respond_to(
48
+ :number,
49
+ :alias,
50
+ :name,
51
+ :enabled,
52
+ :gpg_check,
53
+ :refresh,
54
+ :priority,
55
+ :type,
56
+ :uri,
57
+ :service
58
+ )
59
+ expect(Kanrisuru::Core::Zypper::Service.new).to respond_to(
60
+ :number,
61
+ :alias,
62
+ :name,
63
+ :enabled,
64
+ :gpg_check,
65
+ :refresh,
66
+ :priority,
67
+ :type,
68
+ :uri
69
+ )
70
+ expect(Kanrisuru::Core::Zypper::SearchResult.new).to respond_to(
71
+ :repository,
72
+ :package,
73
+ :status,
74
+ :type,
75
+ :version,
76
+ :architecture
77
+ )
78
+ expect(Kanrisuru::Core::Zypper::PackageDetail.new).to respond_to(
79
+ :repository,
80
+ :package,
81
+ :version,
82
+ :architecture,
83
+ :vendor,
84
+ :support_level,
85
+ :install_size,
86
+ :installed,
87
+ :status,
88
+ :source_package,
89
+ :summary,
90
+ :description
91
+ )
92
+ expect(Kanrisuru::Core::Zypper::PackageUpdate.new).to respond_to(
93
+ :repository,
94
+ :package,
95
+ :current_version,
96
+ :available_version,
97
+ :architecture
98
+ )
99
+ expect(Kanrisuru::Core::Zypper::PatchUpdate.new).to respond_to(
100
+ :repository,
101
+ :patch,
102
+ :category,
103
+ :severity,
104
+ :interactive,
105
+ :status,
106
+ :summary
107
+ )
108
+ expect(Kanrisuru::Core::Zypper::PatchCount.new).to respond_to(
109
+ :category,
110
+ :updatestack,
111
+ :patches
112
+ )
113
+ expect(Kanrisuru::Core::Zypper::Lock.new).to respond_to(
114
+ :number,
115
+ :name,
116
+ :matches,
117
+ :type,
118
+ :repository
119
+ )
120
+ end
121
+ end