racf 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/.gitignore +8 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +18 -0
  4. data/Gemfile +14 -0
  5. data/Gemfile.lock +40 -0
  6. data/README.rdoc +56 -0
  7. data/Rakefile +9 -0
  8. data/TODO.txt +5 -0
  9. data/config/racf.yml.sample +27 -0
  10. data/lib/racf.rb +78 -0
  11. data/lib/racf/client.rb +138 -0
  12. data/lib/racf/commands/abstract_command.rb +13 -0
  13. data/lib/racf/commands/listgrp.rb +189 -0
  14. data/lib/racf/commands/listgrp/group_members_parser.rb +104 -0
  15. data/lib/racf/commands/listuser.rb +112 -0
  16. data/lib/racf/commands/rlist.rb +208 -0
  17. data/lib/racf/commands/search.rb +31 -0
  18. data/lib/racf/pagers/cached_ispf_pager.rb +91 -0
  19. data/lib/racf/pagers/ispf_pager.rb +57 -0
  20. data/lib/racf/s3270.rb +136 -0
  21. data/lib/racf/session.rb +149 -0
  22. data/lib/racf/version.rb +3 -0
  23. data/racf.gemspec +16 -0
  24. data/script/ci +3 -0
  25. data/spec/fixtures/config/racf.yml +9 -0
  26. data/spec/fixtures/listgrp/multiple_groups_multiple_members.txt +26 -0
  27. data/spec/fixtures/listgrp/multiple_members.txt +10 -0
  28. data/spec/fixtures/listgrp/no_members.txt +4 -0
  29. data/spec/fixtures/listgrp/not_found_groups.txt +21 -0
  30. data/spec/fixtures/listgrp/one_group.txt +7 -0
  31. data/spec/fixtures/listgrp/one_group_with_members.txt +13 -0
  32. data/spec/fixtures/listgrp/one_member.txt +7 -0
  33. data/spec/fixtures/listuser/all_users.txt +45 -0
  34. data/spec/fixtures/listuser/just_users_not_found.txt +3 -0
  35. data/spec/fixtures/listuser/one_user.txt +47 -0
  36. data/spec/fixtures/listuser/some_not_found_users.txt +88 -0
  37. data/spec/fixtures/racf_cache_dump.yml +9 -0
  38. data/spec/fixtures/rlist/gims.txt +135 -0
  39. data/spec/fixtures/rlist/gims_with_no_tims.txt +135 -0
  40. data/spec/fixtures/rlist/gims_with_not_found.txt +89 -0
  41. data/spec/fixtures/rlist/just_one_not_found.txt +1 -0
  42. data/spec/fixtures/rlist/multiple_not_found.txt +3 -0
  43. data/spec/fixtures/rlist/rlist_success.txt +50 -0
  44. data/spec/fixtures/rlist/tims_without_users.txt +119 -0
  45. data/spec/fixtures/search/gims.txt +30 -0
  46. data/spec/fixtures/search/tims.txt +30 -0
  47. data/spec/fixtures/session/screen_with_bottom_menu.txt +31 -0
  48. data/spec/fixtures/session/screen_with_top_and_bottom_menu.txt +47 -0
  49. data/spec/fixtures/session/screen_with_top_menu.txt +29 -0
  50. data/spec/fixtures/session/screen_without_menu.txt +13 -0
  51. data/spec/racf/client_spec.rb +155 -0
  52. data/spec/racf/commands/listgrp/group_members_parser_spec.rb +82 -0
  53. data/spec/racf/commands/listgrp_spec.rb +303 -0
  54. data/spec/racf/commands/listuser_spec.rb +123 -0
  55. data/spec/racf/commands/rlist_spec.rb +257 -0
  56. data/spec/racf/commands/search_spec.rb +66 -0
  57. data/spec/racf/pagers/cached_ispf_pager_spec.rb +212 -0
  58. data/spec/racf/pagers/ispf_pager_spec.rb +59 -0
  59. data/spec/racf/session_spec.rb +114 -0
  60. data/spec/racf_spec.rb +106 -0
  61. data/spec/spec_helper.rb +18 -0
  62. data/spec/support/helpers.rb +5 -0
  63. metadata +162 -0
@@ -0,0 +1,31 @@
1
+ INFORMATION FOR GROUP GUASI108
2
+ SUPERIOR GROUP=GUSCADFA OWNER=GUSCADFA
3
+ INSTALLATION DATA=RETIRADA MONTADORAS
4
+ NO MODEL DATA SET
5
+ TERMUACC
6
+ SUBGROUP(S)= GUTCOMEP
7
+ USER(S)= ACCESS= ACCESS COUNT= UNIVERSAL ACCESS=
8
+ AS21508 JOIN 000000 READ
9
+ CONNECT ATTRIBUTES=SPECIAL
10
+ REVOKE DATE=NONE RESUME DATE=NONE
11
+ FA21508 USE 003399 NONE
12
+ CONNECT ATTRIBUTES=NONE
13
+ REVOKE DATE=NONE RESUME DATE=NONE
14
+ Menu List Mode Functions Utilities Help
15
+ ──────────────────────────────────────────────────────────────────────────────
16
+ ISPF Command Shell
17
+ Enter TSO or Workstation commands below:
18
+ ===>
19
+ Place cursor on choice and press enter to Retrieve command
20
+ => LISTGRP (GUASI108)
21
+ => LISTGRP (GUTCOMEP)
22
+ => LISTUSER (FA21508 AS21508)
23
+ => LISTGRP (GUASI075 GUASI108)
24
+ => LISTUSER (FA51838 FA20115 FA75897 FA58550 FA77095 AS04970)
25
+ => LISTUSER (CA15833 CA06829 CD91544 CA03074 CA04281 CA04019 CA15834 CA11821 C
26
+ => LISTUSER (CA02258 CA01465 CA11817 CA04832 CA04279 CA04147 CA04964 CA05328 C
27
+ => LISTUSER (CA15827 CA02809 CA06953 CA04960 CA06821 CA15828 CA04144 CA04276 C
28
+ => LISTUSER (CA01328 CA06132 CA04271 CA03064 CA15824 CA02807 CA02120 CA03065 C
29
+ => LISTUSER (CA15002 CA02249 CA06947 CA03061 CA04006 CA11808 CA91334 CA02118 C
30
+ F1=Help F2=Split F3=Exit F7=Backward F8=Forward F9=Swap
31
+ F10=Actions F12=Cancel
@@ -0,0 +1,47 @@
1
+ Menu List Mode Functions Utilities Help
2
+ ──────────────────────────────────────────────────────────────────────────────
3
+ ISPF Command Shell
4
+ Enter TSO or Workstation commands below:
5
+ ===> LISTGRP (GUASI108 GUASI109)
6
+ Place cursor on choice and press enter to Retrieve command
7
+ => LISTGRP (GUASI109)
8
+ => LISTGRP (GUTCOMEP)
9
+ => LISTGRP (GUASI108)
10
+ => LISTUSER (FA21508 AS21508)
11
+ => LISTGRP (GUASI075 GUASI108)
12
+ => LISTUSER (FA51838 FA20115 FA75897 FA58550 FA77095 AS04970)
13
+ => LISTUSER (CA15833 CA06829 CD91544 CA03074 CA04281 CA04019 CA15834 CA11821 C
14
+ => LISTUSER (CA02258 CA01465 CA11817 CA04832 CA04279 CA04147 CA04964 CA05328 C
15
+ => LISTUSER (CA15827 CA02809 CA06953 CA04960 CA06821 CA15828 CA04144 CA04276 C
16
+ => LISTUSER (CA01328 CA06132 CA04271 CA03064 CA15824 CA02807 CA02120 CA03065 C
17
+ INFORMATION FOR GROUP GUASI108
18
+ SUPERIOR GROUP=GUSCADFA OWNER=GUSCADFA
19
+ INSTALLATION DATA=RETIRADA MONTADORAS
20
+ NO MODEL DATA SET
21
+ TERMUACC
22
+ SUBGROUP(S)= GUTCOMEP
23
+ USER(S)= ACCESS= ACCESS COUNT= UNIVERSAL ACCESS=
24
+ AS21508 JOIN 000000 READ
25
+ CONNECT ATTRIBUTES=SPECIAL
26
+ REVOKE DATE=NONE RESUME DATE=NONE
27
+ FA21508 USE 003399 NONE
28
+ CONNECT ATTRIBUTES=NONE
29
+ REVOKE DATE=NONE RESUME DATE=NONE
30
+ Menu List Mode Functions Utilities Help
31
+ ──────────────────────────────────────────────────────────────────────────────
32
+ ISPF Command Shell
33
+ Enter TSO or Workstation commands below:
34
+ ===>
35
+ Place cursor on choice and press enter to Retrieve command
36
+ => LISTGRP (GUASI108 GUASI109)
37
+ => LISTGRP (GUASI109)
38
+ => LISTGRP (GUTCOMEP)
39
+ => LISTGRP (GUASI108)
40
+ => LISTUSER (FA21508 AS21508)
41
+ => LISTGRP (GUASI075 GUASI108)
42
+ => LISTUSER (FA51838 FA20115 FA75897 FA58550 FA77095 AS04970)
43
+ => LISTUSER (CA15833 CA06829 CD91544 CA03074 CA04281 CA04019 CA15834 CA11821 C
44
+ => LISTUSER (CA02258 CA01465 CA11817 CA04832 CA04279 CA04147 CA04964 CA05328 C
45
+ => LISTUSER (CA15827 CA02809 CA06953 CA04960 CA06821 CA15828 CA04144 CA04276 C
46
+ F1=Help F2=Split F3=Exit F7=Backward F8=Forward F9=Swap
47
+ F10=Actions F12=Cancel
@@ -0,0 +1,29 @@
1
+ Menu List Mode Functions Utilities Help
2
+ ──────────────────────────────────────────────────────────────────────────────
3
+ ISPF Command Shell
4
+ Enter TSO or Workstation commands below:
5
+ ===> LISTGRP (GUASI108 GUASI109)
6
+ Place cursor on choice and press enter to Retrieve command
7
+ => LISTGRP (GUASI109)
8
+ => LISTGRP (GUTCOMEP)
9
+ => LISTGRP (GUASI108)
10
+ => LISTUSER (FA21508 AS21508)
11
+ => LISTGRP (GUASI075 GUASI108)
12
+ => LISTUSER (FA51838 FA20115 FA75897 FA58550 FA77095 AS04970)
13
+ => LISTUSER (CA15833 CA06829 CD91544 CA03074 CA04281 CA04019 CA15834 CA11821 C
14
+ => LISTUSER (CA02258 CA01465 CA11817 CA04832 CA04279 CA04147 CA04964 CA05328 C
15
+ => LISTUSER (CA15827 CA02809 CA06953 CA04960 CA06821 CA15828 CA04144 CA04276 C
16
+ => LISTUSER (CA01328 CA06132 CA04271 CA03064 CA15824 CA02807 CA02120 CA03065 C
17
+ INFORMATION FOR GROUP GUASI108
18
+ SUPERIOR GROUP=GUSCADFA OWNER=GUSCADFA
19
+ INSTALLATION DATA=RETIRADA MONTADORAS
20
+ NO MODEL DATA SET
21
+ TERMUACC
22
+ SUBGROUP(S)= GUTCOMEP
23
+ USER(S)= ACCESS= ACCESS COUNT= UNIVERSAL ACCESS=
24
+ AS21508 JOIN 000000 READ
25
+ CONNECT ATTRIBUTES=SPECIAL
26
+ REVOKE DATE=NONE RESUME DATE=NONE
27
+ FA21508 USE 003399 NONE
28
+ CONNECT ATTRIBUTES=NONE
29
+ REVOKE DATE=NONE RESUME DATE=NONE
@@ -0,0 +1,13 @@
1
+ INFORMATION FOR GROUP GUASI108
2
+ SUPERIOR GROUP=GUSCADFA OWNER=GUSCADFA
3
+ INSTALLATION DATA=RETIRADA MONTADORAS
4
+ NO MODEL DATA SET
5
+ TERMUACC
6
+ SUBGROUP(S)= GUTCOMEP
7
+ USER(S)= ACCESS= ACCESS COUNT= UNIVERSAL ACCESS=
8
+ AS21508 JOIN 000000 READ
9
+ CONNECT ATTRIBUTES=SPECIAL
10
+ REVOKE DATE=NONE RESUME DATE=NONE
11
+ FA21508 USE 003399 NONE
12
+ CONNECT ATTRIBUTES=NONE
13
+ REVOKE DATE=NONE RESUME DATE=NONE
@@ -0,0 +1,155 @@
1
+ require 'spec_helper'
2
+ require 'racf/client'
3
+
4
+ describe Racf::Client do
5
+ let(:session) { double("session") }
6
+ subject { Racf::Client.new(:session => session) }
7
+
8
+ it { should respond_to :user_id, :user_id=, :password, :password=, :server_address,
9
+ :server_address=, :server_port, :server_port=, :script_port=, :caching,
10
+ :caching=, :session, :session= }
11
+
12
+ describe "initialization" do
13
+ it "initializes with config/racf.yml" do
14
+ subject.user_id.should == "test"
15
+ subject.password.should == "secret"
16
+ subject.server_address.should == "127.0.0.1"
17
+ subject.server_port.should == 3270
18
+ subject.script_port.should == 3003
19
+ subject.caching.should == false
20
+ end
21
+
22
+ it "can be initialized with different options" do
23
+ racf = Racf::Client.new(:session => session, :user_id => "john", :caching => true, :server_port => 3333)
24
+ racf.user_id.should == "john"
25
+ racf.server_port.should == 3333
26
+ racf.caching.should == true
27
+ end
28
+ end
29
+
30
+ describe "#start_session" do
31
+ it "starts a racf session" do
32
+ session.should_receive(:start)
33
+
34
+ racf = Racf::Client.new(:session => session)
35
+
36
+ racf.start_session
37
+ end
38
+
39
+ it "ensures the session is finished when an exeption happens" do
40
+ session.as_null_object
41
+ session.should_receive(:finish)
42
+
43
+ racf = Racf::Client.new(:session => session)
44
+
45
+ racf.start_session { fail "error" } rescue nil
46
+ end
47
+
48
+ it "logs any exception" do
49
+ logger = double("logger").as_null_object
50
+ logger.should_receive(:error).with("error")
51
+ Racf.logger = logger
52
+
53
+ session.as_null_object
54
+
55
+ racf = Racf::Client.new(:session => session)
56
+
57
+ racf.start_session { fail "error" } rescue nil
58
+ end
59
+ end
60
+
61
+ describe "#finish_session" do
62
+ it "finishs a racf session" do
63
+ session.stub(:start)
64
+ session.should_receive(:finish)
65
+
66
+ racf = Racf::Client.new(:session => session)
67
+ racf.start_session
68
+
69
+ racf.finish_session
70
+ end
71
+ end
72
+
73
+ describe "#listgrp" do
74
+ it "calls the listgrp command class" do
75
+ session.
76
+ should_receive(:run_command).
77
+ with('LISTGRP (TEST)').
78
+ and_return("")
79
+
80
+ client = Racf::Client.new(:session => session)
81
+
82
+ client.listgrp("TEST")
83
+ end
84
+ end
85
+
86
+ describe "#listuser" do
87
+ it "calls the listuser command class" do
88
+ session.
89
+ should_receive(:run_command).
90
+ with('LISTUSER (TEST)').
91
+ and_return("")
92
+
93
+ client = Racf::Client.new(:session => session)
94
+
95
+ client.listuser("TEST")
96
+ end
97
+ end
98
+
99
+ describe "#rlist" do
100
+ it "calls the rlist command class" do
101
+ session.
102
+ should_receive(:run_command).
103
+ with('RLIST TIMS (123) AUTHUSER').
104
+ and_return("")
105
+
106
+ client = Racf::Client.new(:session => session)
107
+
108
+ client.rlist("TIMS", "123")
109
+ end
110
+ end
111
+
112
+ describe "#search" do
113
+ it "calls the search command class" do
114
+ session.
115
+ should_receive(:run_command).
116
+ with('SEARCH 123').
117
+ and_return("")
118
+
119
+ client = Racf::Client.new(:session => session)
120
+
121
+ client.search("123")
122
+ end
123
+ end
124
+
125
+ describe "#dump_cache" do
126
+ let(:f) { StringIO.new }
127
+
128
+ it "store cache in a yaml file" do
129
+ File.should_receive(:open).with(Racf.dump_file_path, 'w').and_yield(f)
130
+ subject.dump_cache
131
+
132
+ f.string.should == "--- {}\n\n"
133
+ end
134
+ end
135
+
136
+ describe "#load_cache" do
137
+ it "ignores cache if cache file not found" do
138
+ Racf.logger.should_receive(:warn).with("Could not load cache file! Running with empty cache.")
139
+ subject.load_cache
140
+ end
141
+
142
+ context "with cache file" do
143
+ before { Racf.dump_file_path = Racf.root.join("spec", "fixtures", "racf_cache_dump.yml") }
144
+
145
+ it "loads cache from fixture file" do
146
+ subject.should_receive(:cache=).
147
+ with(hash_including("Racf::Commands::Search" => {},
148
+ "Racf::Commands::Listgrp" => {},
149
+ "Racf::Commands::Rlist" => {},
150
+ "Racf::Commands::Listuser" => {}))
151
+ subject.load_cache
152
+ end
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ require 'racf/commands/listgrp/group_members_parser'
4
+
5
+ describe Racf::Commands::Listgrp::GroupMembersParser do
6
+ context "when the group has no members" do
7
+ before do
8
+ @raw_members = File.read("spec/fixtures/listgrp/no_members.txt")
9
+ end
10
+
11
+ it "returns an empty hash" do
12
+ parser = Racf::Commands::Listgrp::GroupMembersParser.new
13
+
14
+ @raw_members.lines do |line|
15
+ parser.parse(line)
16
+ end
17
+
18
+ parser.state.should == "no_members"
19
+ parser.parsed?.should be_true
20
+ parser.members.should == {}
21
+ end
22
+ end
23
+
24
+ context "when the group has just one member" do
25
+ before do
26
+ @raw_members = File.read("spec/fixtures/listgrp/one_member.txt")
27
+ end
28
+
29
+ it "parses the one member attributes" do
30
+ parser = Racf::Commands::Listgrp::GroupMembersParser.new
31
+
32
+ @raw_members.lines do |line|
33
+ line.strip!
34
+ parser.parse(line)
35
+ end
36
+
37
+ parser.parsed?.should be_true
38
+ parser.state.should == "member_processed"
39
+ members = parser.members
40
+
41
+ members["CA7ONL"][:access].should == "USE"
42
+ members["CA7ONL"][:access_count].should == "000886"
43
+ members["CA7ONL"][:universal_access].should == "READ"
44
+ members["CA7ONL"][:connect_attributes].should == "NONE"
45
+ members["CA7ONL"][:revoke_date].should == "NONE"
46
+ members["CA7ONL"][:resume_date].should == "NONE"
47
+ end
48
+ end
49
+
50
+ context "when the group has multiple members" do
51
+ before do
52
+ @raw_members = File.read("spec/fixtures/listgrp/multiple_members.txt")
53
+ end
54
+
55
+ it "parsers multiple members attributes" do
56
+ parser = Racf::Commands::Listgrp::GroupMembersParser.new
57
+
58
+ @raw_members.lines do |line|
59
+ line.strip!
60
+ parser.parse(line)
61
+ end
62
+
63
+ parser.parsed?.should be_true
64
+ parser.state.should == "member_processed"
65
+ members = parser.members
66
+
67
+ members["CA7ONL"][:access].should == "USE"
68
+ members["CA7ONL"][:access_count].should == "000886"
69
+ members["CA7ONL"][:universal_access].should == "READ"
70
+ members["CA7ONL"][:connect_attributes].should == "NONE"
71
+ members["CA7ONL"][:revoke_date].should == "NONE"
72
+ members["CA7ONL"][:resume_date].should == "NONE"
73
+
74
+ members["CA7ICOM"][:access].should == "USE"
75
+ members["CA7ICOM"][:access_count].should == "000201"
76
+ members["CA7ICOM"][:universal_access].should == "NONE"
77
+ members["CA7ONL"][:connect_attributes].should == "NONE"
78
+ members["CA7ONL"][:revoke_date].should == "NONE"
79
+ members["CA7ONL"][:resume_date].should == "NONE"
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,303 @@
1
+ require 'spec_helper'
2
+
3
+ require 'racf/commands/listgrp'
4
+
5
+ describe Racf::Commands::Listgrp do
6
+ context "#extract_resources" do
7
+ it "does not fail" do
8
+ command = Racf::Commands::Listgrp.new(double("session"))
9
+
10
+ expect {
11
+ command.extract_resources
12
+ }.to_not raise_error(NotImplementedError)
13
+ end
14
+
15
+ context "when arguments are arrays" do
16
+ it "returns the group names" do
17
+ command = Racf::Commands::Listgrp.new(double("session"))
18
+ resources = command.extract_resources([['TEST1', 'TEST2']])
19
+
20
+ resources.should eq(['TEST1', 'TEST2'])
21
+ end
22
+ end
23
+
24
+ context "when argument is a string" do
25
+ it "returns the single group wrapped in an array" do
26
+ command = Racf::Commands::Listgrp.new(double("session"))
27
+ resources = command.extract_resources(['TEST1'])
28
+
29
+ resources.should eq(['TEST1'])
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#run" do
35
+ context "logging" do
36
+ let(:session) { double("session") }
37
+ let(:logger) { mock('Logger') }
38
+
39
+ before(:each) do
40
+ @old_logger = Racf.logger
41
+ Racf.logger = logger
42
+
43
+ scraper_raw_output = read_fixture("listgrp/one_group.txt")
44
+
45
+ session.stub(:run_command => scraper_raw_output)
46
+ end
47
+
48
+ after(:each) do
49
+ Racf.logger = @old_logger
50
+ end
51
+
52
+ it "counts correctly" do
53
+ logger.should_receive(:info).with("Processing 1 group(s)").twice
54
+ logger.should_receive(:info).with("Processing group 1 of 1 groups").twice
55
+ logger.should_receive(:info).with("\tGroup name: @PL").twice
56
+ logger.should_not_receive(:info).with("Processing group 2 of 1 groups")
57
+
58
+ command = Racf::Commands::Listgrp.new(session)
59
+ command.run("*")
60
+ command.run("*")
61
+ end
62
+ end
63
+
64
+ context "when the raw output has a group with no members" do
65
+ before do
66
+ scraper_raw_output = read_fixture("listgrp/one_group.txt")
67
+ @session = double("session")
68
+ @session.stub(:run_command => scraper_raw_output)
69
+
70
+ command = Racf::Commands::Listgrp.new(@session)
71
+ @groups = command.run("*")
72
+ @groups = command.run("*")
73
+ end
74
+
75
+ it "extracts the group name" do
76
+ @groups.keys.should include(:@PL)
77
+ end
78
+
79
+ it "extracts the superior group" do
80
+ @groups[:@PL][:superior_group].should == "GUHLQDSN"
81
+ end
82
+
83
+ it "extracts the owner" do
84
+ @groups[:@PL][:owner].should == "GUHLQDSN"
85
+ end
86
+
87
+ it "extracts the group description" do
88
+ @groups[:@PL][:description].should == "PROTEC. HLQ DSN"
89
+ end
90
+
91
+ it "extracts the subgroups" do
92
+ @groups[:@PL][:subgroups].should == []
93
+ end
94
+
95
+ it "extracts the group members" do
96
+ @groups[:@PL][:members].should be_empty
97
+ end
98
+ end
99
+
100
+ context "when the raw output has one group with members" do
101
+ before do
102
+ scraper_raw_output = read_fixture("listgrp/one_group_with_members.txt")
103
+ @session = double("session")
104
+ @session.stub(:run_command => scraper_raw_output)
105
+
106
+ command = Racf::Commands::Listgrp.new(@session)
107
+ @groups = command.run("*")
108
+ end
109
+
110
+ it "extracts the group name" do
111
+ @groups.keys.should include(:CA7GROUP)
112
+ end
113
+
114
+ it "extracts the superior group" do
115
+ @groups[:CA7GROUP][:superior_group].should == "GUTCPPCP"
116
+ end
117
+
118
+ it "extracts the owner" do
119
+ @groups[:CA7GROUP][:owner].should == "FA25909"
120
+ end
121
+
122
+ it "extracts the group description" do
123
+ @groups[:CA7GROUP][:description].should == "GRUPO DE CONTROLE DO CAR-7"
124
+ end
125
+
126
+ it "extracts the subgroups" do
127
+ @groups[:CA7GROUP][:subgroups].should == ["GUTDRIMT", "GUTDRIVE", "GUTDRIVV"]
128
+ end
129
+
130
+ it "extracts the group members" do
131
+ @groups[:CA7GROUP][:members].should have(2).members
132
+
133
+ @groups[:CA7GROUP][:members]["CA7ONL"][:access].should == "USE"
134
+ @groups[:CA7GROUP][:members]["CA7ONL"][:access_count].should == "000886"
135
+ @groups[:CA7GROUP][:members]["CA7ONL"][:universal_access].should == "READ"
136
+ @groups[:CA7GROUP][:members]["CA7ONL"][:connect_attributes].should == "NONE"
137
+ @groups[:CA7GROUP][:members]["CA7ONL"][:revoke_date].should == "NONE"
138
+ @groups[:CA7GROUP][:members]["CA7ONL"][:resume_date].should == "NONE"
139
+
140
+
141
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:access].should == "USE"
142
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:access_count].should == "000201"
143
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:universal_access].should == "NONE"
144
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:connect_attributes].should == "NONE"
145
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:revoke_date].should == "NONE"
146
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:resume_date].should == "NONE"
147
+ end
148
+ end
149
+
150
+ context "when the raw output has multiple groups with multiple members" do
151
+ before do
152
+ scraper_raw_output = read_fixture("listgrp/multiple_groups_multiple_members.txt")
153
+ @session = double("session")
154
+ @session.stub(:run_command => scraper_raw_output)
155
+
156
+ command = Racf::Commands::Listgrp.new(@session)
157
+ @groups = command.run("*")
158
+ end
159
+
160
+ it "extracts the groups' names" do
161
+ @groups.keys.should include(:CA7GROUP)
162
+ @groups.keys.should include(:SYSTRT)
163
+ end
164
+
165
+ it "extracts the superiors groups" do
166
+ @groups[:CA7GROUP][:superior_group].should == "GUTCPPCP"
167
+ @groups[:SYSTRT][:superior_group].should == "SYS1"
168
+ end
169
+
170
+ it "extracts the owners" do
171
+ @groups[:CA7GROUP][:owner].should == "FA25909"
172
+ @groups[:SYSTRT][:owner].should == "SYS1"
173
+ end
174
+
175
+ it "extracts the groups' descriptions" do
176
+ @groups[:CA7GROUP][:description].should == "GRUPO DE CONTROLE DO CAR-7"
177
+ @groups[:SYSTRT][:description].should == "NO DESCRIPTION"
178
+ end
179
+
180
+ it "extracts the subgroups" do
181
+ @groups[:CA7GROUP][:subgroups].should == ["GUTDRIMT", "GUTDRIVE"]
182
+ @groups[:SYSTRT][:subgroups].should == ["GUTDRIVE", "GUTDRIVV"]
183
+ end
184
+
185
+ it "extracts the groups' members" do
186
+ @groups[:CA7GROUP][:members].should have(2).members
187
+
188
+ @groups[:CA7GROUP][:members]["CA7ONL"][:access].should == "USE"
189
+ @groups[:CA7GROUP][:members]["CA7ONL"][:access_count].should == "000886"
190
+ @groups[:CA7GROUP][:members]["CA7ONL"][:universal_access].should == "READ"
191
+ @groups[:CA7GROUP][:members]["CA7ONL"][:connect_attributes].should == "NONE"
192
+ @groups[:CA7GROUP][:members]["CA7ONL"][:revoke_date].should == "NONE"
193
+ @groups[:CA7GROUP][:members]["CA7ONL"][:resume_date].should == "NONE"
194
+
195
+
196
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:access].should == "USE"
197
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:access_count].should == "000201"
198
+ @groups[:CA7GROUP][:members]["CA7ICOM"][:universal_access].should == "NONE"
199
+ @groups[:CA7GROUP][:members]["CA7ONL"][:connect_attributes].should == "NONE"
200
+ @groups[:CA7GROUP][:members]["CA7ONL"][:revoke_date].should == "NONE"
201
+ @groups[:CA7GROUP][:members]["CA7ONL"][:resume_date].should == "NONE"
202
+
203
+
204
+
205
+ @groups[:SYSTRT][:members].should have(2).members
206
+
207
+ @groups[:SYSTRT][:members]["IB00019"][:access].should == "USE"
208
+ @groups[:SYSTRT][:members]["IB00019"][:access_count].should == "000000"
209
+ @groups[:SYSTRT][:members]["IB00019"][:universal_access].should == "NONE"
210
+ @groups[:SYSTRT][:members]["IB00019"][:connect_attributes].should == "NONE"
211
+ @groups[:SYSTRT][:members]["IB00019"][:revoke_date].should == "NONE"
212
+ @groups[:SYSTRT][:members]["IB00019"][:resume_date].should == "NONE"
213
+
214
+ @groups[:SYSTRT][:members]["IB00025"][:access].should == "USE"
215
+ @groups[:SYSTRT][:members]["IB00025"][:access_count].should == "000000"
216
+ @groups[:SYSTRT][:members]["IB00025"][:universal_access].should == "NONE"
217
+ @groups[:SYSTRT][:members]["IB00025"][:connect_attributes].should == "NONE"
218
+ @groups[:SYSTRT][:members]["IB00025"][:revoke_date].should == "NONE"
219
+ @groups[:SYSTRT][:members]["IB00025"][:resume_date].should == "NONE"
220
+ end
221
+ end
222
+
223
+ context "when the raw output has groups not found" do
224
+ before do
225
+ scraper_raw_output = read_fixture("listgrp/not_found_groups.txt")
226
+ @session = double("session")
227
+ @session.stub(:run_command => scraper_raw_output)
228
+
229
+ command = Racf::Commands::Listgrp.new(@session)
230
+ @groups = command.run(["GUASI108", "GUASI075", "GUASI109"])
231
+ end
232
+
233
+ it "ignores the not found groups" do
234
+ @groups.keys.should have(2).groups
235
+ end
236
+
237
+ it "extracts the found groups' names" do
238
+ @groups.keys.should include(:GUASI108)
239
+ @groups.keys.should include(:GUASI109)
240
+ end
241
+
242
+ it "extracts the superiors groups" do
243
+ @groups[:GUASI108][:superior_group].should == "GUSCADFA"
244
+ @groups[:GUASI109][:superior_group].should == "GUSCADFA"
245
+ end
246
+
247
+ it "extracts the owners" do
248
+ @groups[:GUASI108][:owner].should == "GUSCADFA"
249
+ @groups[:GUASI109 ][:owner].should == "GUSCADFA"
250
+ end
251
+
252
+ it "extracts the groups' descriptions" do
253
+ @groups[:GUASI108][:description].should == "RETIRADA MONTADORAS"
254
+ @groups[:GUASI109][:description].should == "FIAT ALL RISK"
255
+ end
256
+
257
+ it "extracts the subgroups" do
258
+ @groups[:GUASI108][:subgroups].should == ["GUTCOMEP"]
259
+ @groups[:GUASI109][:subgroups].should be_empty
260
+ end
261
+
262
+ it "extracts the groups' members" do
263
+ @groups[:GUASI108][:members]["AS21508"][:access].should == "JOIN"
264
+ @groups[:GUASI108][:members]["AS21508"][:access_count].should == "000000"
265
+ @groups[:GUASI108][:members]["AS21508"][:universal_access].should == "READ"
266
+ @groups[:GUASI108][:members]["AS21508"][:connect_attributes].should == "SPECIAL"
267
+ @groups[:GUASI108][:members]["AS21508"][:revoke_date].should == "NONE"
268
+ @groups[:GUASI108][:members]["AS21508"][:resume_date].should == "NONE"
269
+
270
+ @groups[:GUASI108][:members]["FA21508"][:access].should == "USE"
271
+ @groups[:GUASI108][:members]["FA21508"][:access_count].should == "003391"
272
+ @groups[:GUASI108][:members]["FA21508"][:universal_access].should == "NONE"
273
+ @groups[:GUASI108][:members]["FA21508"][:connect_attributes].should == "NONE"
274
+ @groups[:GUASI108][:members]["FA21508"][:revoke_date].should == "NONE"
275
+ @groups[:GUASI108][:members]["FA21508"][:resume_date].should == "NONE"
276
+
277
+ @groups[:GUASI109][:members].should be_empty
278
+ end
279
+ end
280
+
281
+ context "running twice in a row" do
282
+ before do
283
+ one_group_raw_output = read_fixture("listgrp/one_group.txt")
284
+ multiple_groups_raw_output = read_fixture("listgrp/multiple_groups_multiple_members.txt")
285
+
286
+ @session = double("session")
287
+
288
+ @session.stub(:run_command).with("LISTGRP (@PL)") { one_group_raw_output }
289
+ @session.stub(:run_command).with("LISTGRP (CA7GROUP SYSTRT)") { multiple_groups_raw_output }
290
+ end
291
+
292
+ it "should not keep state between two calls using the same command instance" do
293
+ command = Racf::Commands::Listgrp.new(@session)
294
+
295
+ first_group = "@PL"
296
+ command.run(first_group)
297
+
298
+ other_groups = command.run(["CA7GROUP", "SYSTRT"])
299
+ other_groups.keys.should_not include(first_group)
300
+ end
301
+ end
302
+ end
303
+ end