ucert 0.2.57
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +134 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +61 -0
- data/Rakefile +8 -0
- data/TODO +5 -0
- data/bin/ad_dump +74 -0
- data/bin/ad_update +48 -0
- data/bin/adgrep +149 -0
- data/bin/adp_dump +70 -0
- data/bin/aix_dump +69 -0
- data/bin/audiolog_dump +69 -0
- data/bin/bloomberg_dump +69 -0
- data/bin/check21_dump +69 -0
- data/bin/citidirect_be_dump +69 -0
- data/bin/citidirect_sec_dump +69 -0
- data/bin/citrixsf_dump +70 -0
- data/bin/clear_par_dump +70 -0
- data/bin/cmbrun_ny_dump +76 -0
- data/bin/cvm_dump +70 -0
- data/bin/db_direct_dump +69 -0
- data/bin/egifts_dump +68 -0
- data/bin/equinix_dump +69 -0
- data/bin/frb_dump +69 -0
- data/bin/go_contact_dump +16 -0
- data/bin/jpm_dump +69 -0
- data/bin/madison535_dump +70 -0
- data/bin/mantis_dump +79 -0
- data/bin/prime_dump +79 -0
- data/bin/sage100_dump +69 -0
- data/bin/sharefile_dump +69 -0
- data/bin/som_dump +74 -0
- data/bin/stb_dump +69 -0
- data/bin/swift_dump +79 -0
- data/bin/swift_online_dump +69 -0
- data/bin/t24_dump +79 -0
- data/bin/vpn_dump +69 -0
- data/bin/wms_dump +79 -0
- data/bin/yst_dump +79 -0
- data/data/ad/ad_delta.txt +94 -0
- data/data/ad/hosts +421 -0
- data/data/ad/hosts.old +597 -0
- data/data/ad/hosts_old +597 -0
- data/data/ad/ldap_computer.txt +19028 -0
- data/data/ad/ldap_person.txt +41241 -0
- data/data/adp/Active Employee Report.xlsx +0 -0
- data/data/adp/adp_user_map.txt +141 -0
- data/data/aix/EGIFTS1.txt +239 -0
- data/data/aix/NYSWIFT1.txt +222 -0
- data/data/aix/T24_APP1.txt +300 -0
- data/data/aix/T24_DBP.txt +252 -0
- data/data/aix/aix_user_map.txt +46 -0
- data/data/alliance_swift/Swift_Operator_Details.xlsx +0 -0
- data/data/alliance_swift/Swift_Operator_Profiles_Details.xlsx +0 -0
- data/data/alliance_swift/swift_operator_map.txt +22 -0
- data/data/audiolog/Capture_audiolog.PNG +0 -0
- data/data/bloomberg/AccountData.csv +2 -0
- data/data/bloomberg/Capture_SID_download.PNG +0 -0
- data/data/bloomberg/current_subscriptions.csv +11 -0
- data/data/check21/Capture_check21_users.PNG +0 -0
- data/data/citidirect_be/Capture.PNG +0 -0
- data/data/citidirect_be/Capture_new.PNG +0 -0
- data/data/citidirect_be/Capture_new_new.PNG +0 -0
- data/data/citidirect_be/UserProfileEntitlementReport.pdf +0 -0
- data/data/citidirect_be/UserProfileEntitlementsReport.old.xlsx +0 -0
- data/data/citidirect_be/UserProfileEntitlementsReport.xlsx +0 -0
- data/data/citidirect_be/be_user_map.txt +11 -0
- data/data/citidirect_securities/Capture.PNG +0 -0
- data/data/citidirect_securities/User_Entitlements_Report___CLNT.dat +19 -0
- data/data/citidirect_securities/User_Entitlements_Report___CLNT.xml +75 -0
- data/data/citidirect_securities/citidirect_securities_user_map.txt +10 -0
- data/data/citrix_sharefile/ShareFile_Access_Report.xlsx +0 -0
- data/data/citrix_sharefile/sharefile_user_map.txt +33 -0
- data/data/clear_par/ClearPar User Report.xlsx +0 -0
- data/data/clear_par/clear_par_user_map.txt +25 -0
- data/data/cmbrun_ny/CMBNY_Position_Rpt.xlsx +0 -0
- data/data/cmbrun_ny/CMBRUN_USER_RPT.xlsx +0 -0
- data/data/cmbrun_ny/Capture_cmbrun.PNG +0 -0
- data/data/cmbrun_ny/Capture_cmbrun_position.PNG +0 -0
- data/data/cmbrun_ny/crny_access_user_map.txt +55 -0
- data/data/cvm/cvm_user_func.xlsx +0 -0
- data/data/cvm/cvm_user_list.xlsx +0 -0
- data/data/cvm/cvm_user_map.txt +56 -0
- data/data/cvm/cvm_user_role.xlsx +0 -0
- data/data/db_direct/Capture_main.PNG +0 -0
- data/data/db_direct/Capture_rpt.PNG +0 -0
- data/data/db_direct/accountpermission.xlsx +0 -0
- data/data/db_direct/db_direct_user_map.txt +8 -0
- data/data/db_direct/di_direct_user_map.txt +0 -0
- data/data/db_direct/userfulldetail_2016010813232300644912.pdf +0 -0
- data/data/equinix/Secured Access List_CHINA MERCHANTS BANK.xlsx +0 -0
- data/data/equinix/equinix_user_map.txt +29 -0
- data/data/fis_egifts/CHINA_MERCHANTS_BANK_-_USER_ACCOUNT_FUNCTION_REPORT.xlsx +0 -0
- data/data/fis_egifts/egifts_user_map.txt +113 -0
- data/data/fis_prime/Prime_Operator_Rights_Report.xml +41958 -0
- data/data/fis_prime/Prime_Operator_Status_Report.xml +1827 -0
- data/data/fis_prime/Prime_Operators_and_Roles_Report.xml +1505 -0
- data/data/fis_prime/Prime_Rights_by_Role_Report.xml +22726 -0
- data/data/fis_prime/prime_user_map.txt +77 -0
- data/data/frb/FRB_Subscriber_Roles_Report.xlsx +0 -0
- data/data/frb/frb_user_map.txt +22 -0
- data/data/go_contact/go_contact.xlsx +0 -0
- data/data/go_contact/go_user_map.txt +134 -0
- data/data/go_contact/title_level_map.txt +141 -0
- data/data/jpm_access/Capture.PNG +0 -0
- data/data/jpm_access/jpm_access_user_map.txt +13 -0
- data/data/jpm_access/jpm_user_entitlements_details.txt +194 -0
- data/data/jpm_access/jpm_user_groupentitlements_details.txt +2 -0
- data/data/madison535/535madison_bldg_pass.xlsx +0 -0
- data/data/madison535/535madison_bldg_pass_2.xlsx +0 -0
- data/data/madison535/madison535_user_map.txt +191 -0
- data/data/mantis/Mantis_AccessLevels.xlsx +0 -0
- data/data/mantis/Mantis_ActiveUsers_Rpt.xlsx +0 -0
- data/data/mantis/mantis_access_user_map.txt +128 -0
- data/data/sage100/Capture_Sage100_Rpt.PNG +0 -0
- data/data/sage100/Capture_Sage100_Rpt_2.PNG +0 -0
- data/data/sage100/SY_UserReport_RolePreferencesDetails.xlsx +0 -0
- data/data/sage100/SY_UserReport_RoleTaskPermissionsDetails.xlsx +0 -0
- data/data/sage100/sy_user_map.txt +14 -0
- data/data/som/som_user_map.txt +40 -0
- data/data/som/som_user_report.csv +329 -0
- data/data/stb/STB_USERS.csv +177 -0
- data/data/stb/STB_USERS.pdf +0 -0
- data/data/stb/stb_user_map.txt +33 -0
- data/data/swift_online/UserReport.xlsx +0 -0
- data/data/swift_online/swo_access_user_map.txt +18 -0
- data/data/t24/T24_Grp_Rpt.csv +484 -0
- data/data/t24/T24_User_Rpt.csv +567 -0
- data/data/t24/t24_grp.xml +2904 -0
- data/data/t24/t24_user_map.txt +197 -0
- data/data/t24/t24_usr.xml +9628 -0
- data/data/vpn/Capture_VPN.PNG +0 -0
- data/data/wms/role_rpt.txt +451 -0
- data/data/wms/user_rpt.txt +55 -0
- data/data/wms/wms_user_map.txt +55 -0
- data/data/yst/YiShiTong_Org.csv +21 -0
- data/data/yst/YiShiTong_User.csv +163 -0
- data/data/yst/yst_user_map.txt +163 -0
- data/demos/filter_email.rb +19 -0
- data/demos/idm_ad_reload.rb +164 -0
- data/lib/ucert.rb +82 -0
- data/lib/ucert/ad_tracker.rb +694 -0
- data/lib/ucert/adp_payroll_tracker.rb +189 -0
- data/lib/ucert/aix_tracker.rb +175 -0
- data/lib/ucert/alliance_swift_tracker.rb +300 -0
- data/lib/ucert/audiolog_tracker.rb +67 -0
- data/lib/ucert/bloomberg_tracker.rb +96 -0
- data/lib/ucert/check21_tracker.rb +95 -0
- data/lib/ucert/citidirect_be_tracker.rb +418 -0
- data/lib/ucert/citidirect_securities_tracker.rb +230 -0
- data/lib/ucert/citrix_sharefile_tracker.rb +196 -0
- data/lib/ucert/clear_par_tracker.rb +187 -0
- data/lib/ucert/cmbrun_ny_tracker.rb +244 -0
- data/lib/ucert/cvm_tracker.rb +230 -0
- data/lib/ucert/db_direct_tracker.rb +205 -0
- data/lib/ucert/equinix_tracker.rb +202 -0
- data/lib/ucert/fis_egifts_tracker.rb +249 -0
- data/lib/ucert/fis_prime_tracker.rb +391 -0
- data/lib/ucert/frb_tracker.rb +232 -0
- data/lib/ucert/go_contact_tracker.rb +778 -0
- data/lib/ucert/jpm_access_tracker.rb +205 -0
- data/lib/ucert/madison535_tracker.rb +273 -0
- data/lib/ucert/mantis_tracker.rb +249 -0
- data/lib/ucert/sage100_tracker.rb +355 -0
- data/lib/ucert/som_tracker.rb +223 -0
- data/lib/ucert/stb_tracker.rb +199 -0
- data/lib/ucert/swift_online_tracker.rb +197 -0
- data/lib/ucert/t24_tracker.rb +342 -0
- data/lib/ucert/utils/utils.rb +200 -0
- data/lib/ucert/vpn_tracker.rb +94 -0
- data/lib/ucert/wms_tracker.rb +240 -0
- data/lib/ucert/yst_tracker.rb +264 -0
- data/test/ad_testfiles/ldap_computer_test.txt +21 -0
- data/test/ad_testfiles/ldap_person_test.txt +21 -0
- data/test/aix_testfiles/application1.txt +7 -0
- data/test/aix_testfiles/application2.txt +15 -0
- data/test/alliance_swift_testfiles/Swift_Operator_Details_Test.xlsx +0 -0
- data/test/alliance_swift_testfiles/Swift_Operator_Profiles_Details_Test.xlsx +0 -0
- data/test/alliance_swift_testfiles/swift_operator_map_test.txt +55 -0
- data/test/alliance_swift_testfiles/swift_operator_map_test_2.txt +55 -0
- data/test/alliance_swift_testfiles/swift_operator_map_test_format_fixed.txt +55 -0
- data/test/citidirect_be_testfiles/UserProfileEntitlementsReport_Test.xlsx +0 -0
- data/test/citidirect_securities_testfiles/User_Entitlements_Report___CLNT_Test.xml +48 -0
- data/test/citrix_sharefile_testfiles/ShareFile_Access_Report_Test.xlsx +0 -0
- data/test/cmbrun_ny_testfiles/CMBNY_Position_Rpt_02242016_test.xlsx +0 -0
- data/test/cmbrun_ny_testfiles/CMBRUN_USER_RPT_Test.xlsx +0 -0
- data/test/db_direct_testfiles/accountpermission_Test.xlsx +0 -0
- data/test/equinix_testfiles/Secured Access List_CHINA MERCHANTS BANK_TEST.xlsx +0 -0
- data/test/fis_egifts_testfiles/CHINA_MERCHANTS_BANK_-_USER_ACCOUNT_FUNCTION_REPORT_TEST.xlsx +0 -0
- data/test/fis_prime_testfiles/Prime_Operator_Rights_Report_Test.xml +158 -0
- data/test/fis_prime_testfiles/Prime_Operator_Status_Report_Copy.xml +1659 -0
- data/test/fis_prime_testfiles/Prime_Operator_Status_Report_Test.xml +51 -0
- data/test/fis_prime_testfiles/Prime_Operators_and_Roles_Report_Copy.xml +1360 -0
- data/test/fis_prime_testfiles/Prime_Operators_and_Roles_Report_Test.xml +45 -0
- data/test/fis_prime_testfiles/Prime_Rights_by_Role_Report_Test.xml +65 -0
- data/test/fis_prime_testfiles/prime_user_map.txt +3 -0
- data/test/frb_testfiles/FRB_Subscriber_Roles_Report_Test.xlsx +0 -0
- data/test/go_contact_testfiles/go_contact_test.xlsx +0 -0
- data/test/jpm_access_testfiles/Capture.PNG +0 -0
- data/test/jpm_access_testfiles/jpm_user_entitlements_details_original.txt +208 -0
- data/test/jpm_access_testfiles/jpm_user_entitlements_details_test.txt +7 -0
- data/test/madison535_testfiles/535madison_bldg_pass_2_Test.xlsx +0 -0
- data/test/madison535_testfiles/535madison_bldg_pass_Test.xlsx +0 -0
- data/test/mantis_testfiles/Mantis_AccessLevels_Test.xlsx +0 -0
- data/test/mantis_testfiles/Mantis_ActiveUsers_Rpt_Test.xlsx +0 -0
- data/test/sage100_testfiles/SY_UserReport_RolePreferencesDetails_Test.xlsx +0 -0
- data/test/sage100_testfiles/SY_UserReport_RoleTaskPermissionsDetails_Test.xlsx +0 -0
- data/test/som_testfiles/som_user_map_test.txt +7 -0
- data/test/som_testfiles/som_user_report_test.csv +25 -0
- data/test/stb_testfiles/STB_USERS_test.csv +24 -0
- data/test/stb_testfiles/STB_USERS_test_constant.csv +24 -0
- data/test/swift_online_testfiles/UserReport.xls +0 -0
- data/test/swift_online_testfiles/UserReport_Test.xlsx +0 -0
- data/test/swift_online_testfiles/test_outline_level.rb +7 -0
- data/test/t24_testfiles/T24_Grp_Rpt_Test.csv +7 -0
- data/test/t24_testfiles/T24_User_Rpt_Test.csv +7 -0
- data/test/test_ad_tracker.rb +148 -0
- data/test/test_aix_tracker.rb +71 -0
- data/test/test_alliance_swift_tracker.rb +131 -0
- data/test/test_audiolog_tracker.rb +23 -0
- data/test/test_check21_tracker.rb +30 -0
- data/test/test_citidirect_be_tracker.rb +110 -0
- data/test/test_citidirect_securities_tracker.rb +89 -0
- data/test/test_citrix_sharefile_tracker.rb +105 -0
- data/test/test_cmbrun_ny_tracker.rb +112 -0
- data/test/test_db_direct_tracker.rb +125 -0
- data/test/test_equinix_tracker.rb +119 -0
- data/test/test_fis_egifts_tracker.rb +105 -0
- data/test/test_fis_prime_tracker.rb +288 -0
- data/test/test_frb_tracker.rb +104 -0
- data/test/test_go_contact.rb +276 -0
- data/test/test_jpm_access_tracker.rb +122 -0
- data/test/test_madison535_tracker.rb +125 -0
- data/test/test_mantis_tracker.rb +133 -0
- data/test/test_sage100_tracker.rb +120 -0
- data/test/test_som_tracker.rb +71 -0
- data/test/test_stb_tracker.rb +120 -0
- data/test/test_swift_online_tracker.rb +116 -0
- data/test/test_t24_tracker.rb +151 -0
- data/test/test_utils.rb +46 -0
- data/test/test_vpn_tracker.rb +56 -0
- data/test/test_wms_tracker.rb +109 -0
- data/test/test_yst_tracker.rb +133 -0
- data/test/utils_testfiles/file2list_test.txt +13 -0
- data/test/utils_testfiles/load_know_user_map_testfile.txt +4 -0
- data/test/wms_testfiles/role_rpt_test.txt +6 -0
- data/test/wms_testfiles/user_rpt_test.txt +6 -0
- data/test/yst_testfiles/YiShiTong_Org_Test.csv +18 -0
- data/test/yst_testfiles/YiShiTong_User_Test.csv +5 -0
- data/ucert.gemspec +52 -0
- data/version.txt +12 -0
- metadata +410 -0
@@ -0,0 +1,276 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "ucert"
|
3
|
+
|
4
|
+
class TestGoTracker < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@go_contact_tracker = Ucert::GoTracker.new(:verbose=>false)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_instance_initialize_success
|
11
|
+
refute_nil @go_contact_tracker.go_contact_0
|
12
|
+
refute_nil @go_contact_tracker.go_contact_1
|
13
|
+
refute_nil @go_contact_tracker.org_chart
|
14
|
+
refute_nil @go_contact_tracker.go_dptm
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_parse_go_contact_full_time
|
18
|
+
@test_full_time=@go_contact_tracker.send(:parse_go_contact, File.dirname(__FILE__)+"/go_contact_testfiles/go_contact_test.xlsx")[0]
|
19
|
+
@test_full_time.each do |index, user|
|
20
|
+
if index >=3
|
21
|
+
break
|
22
|
+
else
|
23
|
+
user.each do |key, value|
|
24
|
+
if key=="employment_status"
|
25
|
+
case index
|
26
|
+
when 0
|
27
|
+
assert_equal "full time", value
|
28
|
+
when 1
|
29
|
+
assert_equal "temp", value
|
30
|
+
when 2
|
31
|
+
assert_equal "temp", value
|
32
|
+
when 3
|
33
|
+
assert_equal "full time", value
|
34
|
+
else
|
35
|
+
end
|
36
|
+
elsif key=="title"
|
37
|
+
case index
|
38
|
+
when 0
|
39
|
+
assert_equal "full time", value
|
40
|
+
when 1
|
41
|
+
assert_equal "temp_risk", value
|
42
|
+
when 2
|
43
|
+
assert_equal "temp_IT", value
|
44
|
+
when 3
|
45
|
+
assert_equal "", value
|
46
|
+
else
|
47
|
+
end
|
48
|
+
else
|
49
|
+
assert_equal "test#{index+1}\\#{key}", value.downcase
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_parse_go_contact_intern
|
57
|
+
@test_intern=@go_contact_tracker.send(:parse_go_contact, File.dirname(__FILE__)+"/go_contact_testfiles/go_contact_test.xlsx")[1]
|
58
|
+
@test_intern.each do |index, user|
|
59
|
+
if index >=3
|
60
|
+
break
|
61
|
+
else
|
62
|
+
user.each do |key, value|
|
63
|
+
if key=="employment_status"
|
64
|
+
assert_equal "intern", value
|
65
|
+
else
|
66
|
+
assert_equal "intern#{index+1}\\#{key}", value.downcase
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def test_insert_dn
|
75
|
+
@go_contact_tracker.go_contact_0.each do |index, user|
|
76
|
+
dn_regex=/\ACN=.+\,OU=.+\,DC=ny,DC=cmbchina,DC=com\z/
|
77
|
+
assert_match dn_regex, user["DN"] unless user["DN"].nil?
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#Test will fail for method go_search_by_dn, since hash['dn'] should use 'DN' as key.
|
82
|
+
def test_go_search_by_dn
|
83
|
+
FileUtils.cp_r(File.dirname(__FILE__)+"/../data/go_contact/go_user_map.txt", File.dirname(__FILE__)+"/go_contact_testfiles/go_user_map_test.txt")
|
84
|
+
index=0
|
85
|
+
test_pair=Hash.new
|
86
|
+
File.open(File.dirname(__FILE__)+"/go_contact_testfiles/go_user_map_test.txt", 'r').each_line do |line|
|
87
|
+
if index>0
|
88
|
+
key=line.split("@")[0]
|
89
|
+
dn=line.split("|")[1].strip
|
90
|
+
test_pair.merge!({key=>dn})
|
91
|
+
if dn==""
|
92
|
+
refute @go_contact_tracker.send(:search_by_dn, dn)['DN']
|
93
|
+
else
|
94
|
+
assert_equal dn, @go_contact_tracker.send(:search_by_dn, dn)['DN']
|
95
|
+
end
|
96
|
+
end
|
97
|
+
index=index+1
|
98
|
+
end
|
99
|
+
test_pair.each do |key, dn|
|
100
|
+
if dn==""
|
101
|
+
refute @go_contact_tracker.send(:go_searches_by_text, key).first
|
102
|
+
else
|
103
|
+
assert_equal dn, @go_contact_tracker.send(:go_searches_by_text, key).first
|
104
|
+
end
|
105
|
+
end
|
106
|
+
File.delete(File.dirname(__FILE__)+"/go_contact_testfiles/go_user_map_test.txt")
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_go_searches_by_text
|
110
|
+
risk_group=Array.new
|
111
|
+
go_contact=["go_contact_0","go_contact_1"]
|
112
|
+
go_contact.each do |go|
|
113
|
+
@go_contact_tracker.send(go).values.map do |entry|
|
114
|
+
if entry['department']=="Risk Management"
|
115
|
+
risk_group.push(entry["DN"])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
assert_equal risk_group, @go_contact_tracker.send(:go_searches_by_text, "risk")
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_save_go_user_map
|
123
|
+
@go_contact_tracker.send(:save!, File.dirname(__FILE__)+"/go_contact_testfiles/go_user_map_test.txt")
|
124
|
+
line_count=0
|
125
|
+
File.open(File.dirname(__FILE__)+"/go_contact_testfiles/go_user_map_test.txt", 'r').each_line do |line|
|
126
|
+
if line_count==0
|
127
|
+
assert_match (/\# local Go Contact to AD user map file created by the .+ class .+ method at: .+/), line
|
128
|
+
else
|
129
|
+
assert_match (/\A[\w+\-.]+@ny.cmbchina.com\z/), line.split("|")[0].downcase
|
130
|
+
assert_match (/\ACN=.+\,OU=.+\,DC=ny,DC=cmbchina,DC=com\z/), line.split("|")[1].strip unless line.split("|")[1].strip.empty?
|
131
|
+
end
|
132
|
+
line_count+=1
|
133
|
+
end
|
134
|
+
go_contact=["go_contact_0","go_contact_1"]
|
135
|
+
num=go_contact.inject(0){|user_num, sheet| user_num+@go_contact_tracker.send(sheet).size}
|
136
|
+
#go_contact information is not updated, so there is some error between go_contact and ad.
|
137
|
+
#assert_equal line_count-1, num
|
138
|
+
File.delete(File.dirname(__FILE__)+"/go_contact_testfiles/go_user_map_test.txt")
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_export_go_contact_sheet_and_write_wookbook
|
142
|
+
output_full_time=Array.new
|
143
|
+
output_full_time[0]={"department"=>"Full1-1", "title"=>"Full1-2", "en_name"=>"Full1-3", "cn_name_pinyin"=>"Full1-4",
|
144
|
+
"cn_name"=>"Full1-5", "wk_phone"=>"Full1-6", "wk_phone_ext"=>"Full1-7", "cell_phone"=>"Full1-8", "email"=>"Full1-9"}
|
145
|
+
output_full_time[1]={"department"=>"Full2-1", "title"=>"Full2-2", "en_name"=>"Full2-3", "cn_name_pinyin"=>"Full2-4",
|
146
|
+
"cn_name"=>"Full2-5", "wk_phone"=>"Full2-6", "wk_phone_ext"=>"Full2-7", "cell_phone"=>"Full2-8", "email"=>"Full2-9"}
|
147
|
+
output_intern=Array.new
|
148
|
+
output_intern[0]={"department"=>"Intern1-1", "title"=>"Intern1-2", "en_name"=>"Intern1-3", "cn_name_pinyin"=>"Intern1-4",
|
149
|
+
"cn_name"=>"Intern1-5", "wk_phone"=>"Intern1-6", "wk_phone_ext"=>"Intern1-7", "cell_phone"=>"Intern1-8", "email"=>"Intern1-9"}
|
150
|
+
output_intern[1]={"department"=>"Intern2-1", "title"=>"Intern2-2", "en_name"=>"Intern2-3", "cn_name_pinyin"=>"Intern2-4",
|
151
|
+
"cn_name"=>"Intern2-5", "wk_phone"=>"Intern2-6", "wk_phone_ext"=>"Intern2-7", "cell_phone"=>"Intern2-8", "email"=>"Intern2-9"}
|
152
|
+
workbook=RubyXL::Workbook.new
|
153
|
+
workbook=@go_contact_tracker.send(:export_go_contact_sheet, output_full_time, output_intern)
|
154
|
+
row_index=0
|
155
|
+
workbook[0].each do |row|
|
156
|
+
if row_index==0
|
157
|
+
assert_equal "China Merchants Bank Contact Sheet "+ Time.now.year.to_s, row[0].value.to_s.strip
|
158
|
+
elsif row_index==1
|
159
|
+
str1=""
|
160
|
+
for i in 0..8 do
|
161
|
+
str1=str1+row[i].value.to_s.strip+"/"
|
162
|
+
end
|
163
|
+
assert_equal "Department/Title/English Name/Chinese Name/Chinese Name/Work Phone/Ext./Cell Number/E-mail Address/", str1
|
164
|
+
elsif row_index<4
|
165
|
+
str1=""
|
166
|
+
for i in 0..8 do
|
167
|
+
str1=str1+row[i].value.to_s.strip+"/"
|
168
|
+
end
|
169
|
+
str2=""
|
170
|
+
output_full_time[row_index-2].values.each do |cell|
|
171
|
+
str2=str2+cell.to_s.strip+"/"
|
172
|
+
end
|
173
|
+
assert_equal str2, str1
|
174
|
+
else
|
175
|
+
assert_equal "CMB IT Dept. Disaster Recovery Lines", row[0].value.to_s.strip
|
176
|
+
break
|
177
|
+
end
|
178
|
+
row_index+=1
|
179
|
+
end
|
180
|
+
row_index=0
|
181
|
+
workbook[1].each do |row|
|
182
|
+
if row_index==0
|
183
|
+
assert_equal "China Merchants Bank Contact Sheet "+Time.now.year.to_s, row[0].value.to_s.strip
|
184
|
+
elsif row_index==1
|
185
|
+
str1=""
|
186
|
+
for i in 0..8 do
|
187
|
+
str1=str1+row[i].value.to_s.strip+"/"
|
188
|
+
end
|
189
|
+
assert_equal "Department/Title/English Name/Chinese Name/Chinese Name/Work Phone/Ext./Cell Number/E-mail Address/", str1
|
190
|
+
elsif row_index<4
|
191
|
+
str1=""
|
192
|
+
for i in 0..8 do
|
193
|
+
str1=str1+row[i].value.to_s.strip+"/"
|
194
|
+
end
|
195
|
+
str2=""
|
196
|
+
output_intern[row_index-2].values.each do |cell|
|
197
|
+
str2=str2+cell.to_s.strip+"/"
|
198
|
+
end
|
199
|
+
assert_equal str2, str1
|
200
|
+
else
|
201
|
+
assert_equal "CMB IT Dept. Disaster Recovery Lines", row[0].value.to_s.strip
|
202
|
+
break
|
203
|
+
end
|
204
|
+
row_index+=1
|
205
|
+
end
|
206
|
+
@go_contact_tracker.write_wookbook(workbook, File.dirname(__FILE__)+"/go_contact_testfiles/go_contact_test2.xlsx")
|
207
|
+
assert File.open(File.dirname(__FILE__)+"/go_contact_testfiles/go_contact_test2.xlsx")
|
208
|
+
File.delete(File.dirname(__FILE__)+"/go_contact_testfiles/go_contact_test2.xlsx")
|
209
|
+
end
|
210
|
+
=begin #the feature is not in use anymore
|
211
|
+
def test_org_chart
|
212
|
+
org_chart = Hash.new
|
213
|
+
org_chart["GM"] = Hash.new
|
214
|
+
org_chart["GM"]["Name"] = "GM_Name"
|
215
|
+
org_chart["GM"]["DN"] = "GM_DN"
|
216
|
+
org_chart["GM"]["DGM"] = Hash.new
|
217
|
+
org_chart["GM"]["DGM"]["Name"] = "GM_DGM_Name"
|
218
|
+
org_chart["GM"]["DGM"]["DN"] = "GM_DGM_DN"
|
219
|
+
org_chart["GM"]["AGM1"] = Hash.new
|
220
|
+
org_chart["GM"]["AGM1"]["Name"] = "GM_AGM1_Name"
|
221
|
+
org_chart["GM"]["AGM1"]["DN"] = "GM_AGM1_DN"
|
222
|
+
org_chart["GM"]["AGM2"] = Hash.new
|
223
|
+
org_chart["GM"]["AGM2"]["Name"] = "GM_AGM2_Name"
|
224
|
+
org_chart["GM"]["AGM2"]["DN"] = "GM_AGM2_DN"
|
225
|
+
org_chart["GM"]["TRE"] = Hash.new
|
226
|
+
org_chart["GM"]["TRE"]["Name"] = "GM_TRE_Name"
|
227
|
+
org_chart["GM"]["TRE"]["DN"] = "GM_TRE_DN"
|
228
|
+
org_chart["GM"]["FI"] = Hash.new
|
229
|
+
org_chart["GM"]["FI"]["Name"] = "GM_FI_Name"
|
230
|
+
org_chart["GM"]["FI"]["DN"] = "GM_FI_DN"
|
231
|
+
org_chart["GM"]["PB"] = Hash.new
|
232
|
+
org_chart["GM"]["PB"]["Name"] = "GM_PB_Name"
|
233
|
+
org_chart["GM"]["PB"]["DN"] = "GM_PB_DN"
|
234
|
+
org_chart["GM"]["SBD"] = Hash.new
|
235
|
+
org_chart["GM"]["SBD"]["Name"] = "GM_SBD_Name"
|
236
|
+
org_chart["GM"]["SBD"]["DN"] = "GM_SBD_DN"
|
237
|
+
org_chart["GM"]["HRGO"] = Hash.new
|
238
|
+
org_chart["GM"]["HRGO"]["Name"] = "GM_HRGO_Name"
|
239
|
+
org_chart["GM"]["HRGO"]["DN"] = "GM_HRGO_DN"
|
240
|
+
org_chart["GM"]["DGM"]["CBI"] = Hash.new
|
241
|
+
org_chart["GM"]["DGM"]["CBI"]["Name"] = "GM_DGM_CBI_Name"
|
242
|
+
org_chart["GM"]["DGM"]["CBI"]["DN"] = "GM_DGM_CBI_DN"
|
243
|
+
org_chart["GM"]["DGM"]["CBII"] = Hash.new
|
244
|
+
org_chart["GM"]["DGM"]["CBII"]["Name"] = "GM_DGM_CBII_Name"
|
245
|
+
org_chart["GM"]["DGM"]["CBII"]["DN"] = "GM_DGM_CBII_DN"
|
246
|
+
org_chart["GM"]["DGM"]["CPG"] = Hash.new
|
247
|
+
org_chart["GM"]["DGM"]["CPG"]["Name"] = "GM_DGM_CPG_Name"
|
248
|
+
org_chart["GM"]["DGM"]["CPG"]["DN"] = "GM_DGM_CPG_DN"
|
249
|
+
org_chart["GM"]["DGM"]["IB"] = Hash.new
|
250
|
+
org_chart["GM"]["DGM"]["IB"]["Name"] = "GM_DGM_IB_Name"
|
251
|
+
org_chart["GM"]["DGM"]["IB"]["DN"] = "GM_DGM_IB_DN"
|
252
|
+
org_chart["GM"]["AGM1"]["Risk"] = Hash.new
|
253
|
+
org_chart["GM"]["AGM1"]["Risk"]["Name"] = "GM_AGM1_Risk_Name"
|
254
|
+
org_chart["GM"]["AGM1"]["Risk"]["DN"] = "GM_AGM1_Risk_DN"
|
255
|
+
org_chart["GM"]["AGM1"]["FA"] = Hash.new
|
256
|
+
org_chart["GM"]["AGM1"]["FA"]["Name"] = "GM_AGM1_FA_Name"
|
257
|
+
org_chart["GM"]["AGM1"]["FA"]["DN"] = "GM_AGM1_FA_DN"
|
258
|
+
org_chart["GM"]["AGM1"]["LC"] = Hash.new
|
259
|
+
org_chart["GM"]["AGM1"]["LC"]["Name"] = "GM_AGM1_LC_Name"
|
260
|
+
org_chart["GM"]["AGM1"]["LC"]["DN"] = "GM_AGM1_LC_DN"
|
261
|
+
org_chart["GM"]["AGM2"]["TB"] = Hash.new
|
262
|
+
org_chart["GM"]["AGM2"]["TB"]["Name"] = "GM_AGM2_TB_Name"
|
263
|
+
org_chart["GM"]["AGM2"]["TB"]["DN"] = "GM_AGM2_TB_DN"
|
264
|
+
org_chart["GM"]["AGM2"]["OPS"] = Hash.new
|
265
|
+
org_chart["GM"]["AGM2"]["OPS"]["Name"] = "GM_AGM2_OPS_Name"
|
266
|
+
org_chart["GM"]["AGM2"]["OPS"]["DN"] = "GM_AGM2_OPS_DN"
|
267
|
+
org_chart["GM"]["AGM2"]["IT"] = Hash.new
|
268
|
+
org_chart["GM"]["AGM2"]["IT"]["Name"] = "GM_AGM2_IT_Name"
|
269
|
+
org_chart["GM"]["AGM2"]["IT"]["DN"] = "GM_AGM2_IT_DN"
|
270
|
+
puts org_chart
|
271
|
+
@go_contact_tracker.org_chart = org_chart
|
272
|
+
puts @go_contact_tracker.org_chart
|
273
|
+
refute_nil @go_contact_tracker.go_dptm
|
274
|
+
end
|
275
|
+
=end
|
276
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "ucert"
|
3
|
+
|
4
|
+
class TestJpmAccessTracker < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@jpm_tracker = Ucert::JpmAccessTracker.new(:verbose=>false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_instance_initialize_success
|
10
|
+
refute_nil @jpm_tracker.file_jpm_user_map
|
11
|
+
refute_nil @jpm_tracker.jpm_2_ad_user
|
12
|
+
refute_nil @jpm_tracker.jpm_user_entitlement
|
13
|
+
end
|
14
|
+
|
15
|
+
# infromation in the first row is not recorded except first user, which causes failure.
|
16
|
+
def test_parse_jpm_user_entitlement_report
|
17
|
+
=begin #prepare test_file, only uncomment it when test_file is empty
|
18
|
+
doc = File.open(File.dirname(__FILE__)+"/jpm_access_testfiles/jpm_user_entitlements_details_test.txt",'w')
|
19
|
+
doc.write("User First Name|User Middle Initial|User Last Name|Job Title|User ID|Logon Type|Employee ID|User Status|Email|Address Line 1|Address Line 2|City|State/Province/Region|Zip/Postal Code|Country|Phone 1|Phone 1 Extension|Phone 1 Type|Phone 2|Phone 2 Extension|Phone 2 Type|Phone 3|Phone 3 Extension|Phone 3 Type|Last Logon Date|Last Modified Date|Last Modified By|Member of User Group Name|Member of User Group Description|Product Name|Product Entitlement Method|Sub Product Name|Sub Product Entitlement Method|Function Type|Function Name|Function Name Entitlement Method|Function Status|Limit Product|User Attribute|Payment/Transaction Limit|Payment/Transaction Limit Entitlement Method|Batch Limit|Batch Limit Entitlement Method|Daily Limit|Daily Limit Entitlement Method|Acct Group Name|Acct Group Entitlement Method|FX Acct Group Name|FX Acct Group Entitlement Method|Eligible For|Acct Name/NickName|Acct Number/TPA/Program ID|Account Entitlement Method|Parent Billing Group Number|Parent Billing Group Entitlement Method|Billing Account Group Name|Billing Account Name|Billing Account Entitlement Method|Confidential Transaction|Bank|Currency|Account Transfer - Transfer Direction|All ACH Credit Limit|Credit Limit Entitlement Method|All ACH Debit Limit|Debit Limit Entitlement Method|FX Daily Trans. Limit|FX Daily Trans. Limit Currency|FX Daily Limit Entitlement Method|FX Individual Trans. Limit|FX Individual Trans. Limit Currency|FX Individual Limit Entitlement Method|ACH Company Name|ACH Company ID|ACH Company Entitlement Method|Arrangement Name|Currency Name|Restricted Country Entitlement Method|More Services|Description Country|View Payroll Summary|")
|
20
|
+
doc.write("\n")
|
21
|
+
for kk in 1..3 do
|
22
|
+
for ii in 1..kk do
|
23
|
+
for jj in 1..27 do
|
24
|
+
doc.write("Test"+kk.to_s+":"+jj.to_s+"|")
|
25
|
+
end
|
26
|
+
for jj in 28..79 do
|
27
|
+
doc.write("Test"+kk.to_s+":"+ii.to_s+":"+jj.to_s+"|")
|
28
|
+
end
|
29
|
+
doc.write("\n")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
doc.close
|
33
|
+
=end
|
34
|
+
@test_entitlement= @jpm_tracker.send(:parse_jpm_user_entitlement_report, File.dirname(__FILE__)+"/jpm_access_testfiles/jpm_user_entitlements_details_test.txt")
|
35
|
+
assert_equal 3, @test_entitlement.size
|
36
|
+
#puts @test_entitlement
|
37
|
+
#count=1
|
38
|
+
for kk in 1..3 do
|
39
|
+
for ii in 1..kk do
|
40
|
+
for jj in 1..27 do
|
41
|
+
# puts count
|
42
|
+
assert_equal "Test"+kk.to_s+":"+jj.to_s, @test_entitlement[kk].values[jj-1]
|
43
|
+
# count+=1
|
44
|
+
end
|
45
|
+
for jj in 28..79 do
|
46
|
+
# puts count
|
47
|
+
assert_equal "Test"+kk.to_s+":"+ii.to_s+":"+jj.to_s, (@test_entitlement[kk].values[27][ii-1].values)[jj-28]
|
48
|
+
# count+=1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_dn_2_index
|
55
|
+
=begin
|
56
|
+
FileUtils.cp_r(File.dirname(__FILE__)+"/../data/jpm_access/jpm_access_user_map.txt", File.dirname(__FILE__)+"/jpm_access_testfiles/jpm_access_user_map_test.txt")
|
57
|
+
line_cnt=1
|
58
|
+
File.open(File.dirname(__FILE__)+"/jpm_access_testfiles/jpm_access_user_map_test.txt", 'r').each_line do |line|
|
59
|
+
if line_cnt>1
|
60
|
+
dn=line.split("|")[1].strip
|
61
|
+
assert_equal line_cnt-1, @jpm_tracker.send(:dn_2_index, dn)
|
62
|
+
end
|
63
|
+
line_cnt+=1
|
64
|
+
end
|
65
|
+
File.delete(File.dirname(__FILE__)+"/jpm_access_testfiles/jpm_access_user_map_test.txt")
|
66
|
+
=end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_insert_dn
|
70
|
+
@jpm_tracker.jpm_user_entitlement.each do |index, user|
|
71
|
+
dn_regex=/\ACN=.+\,OU=.+\,DC=ny,DC=cmbchina,DC=com\z/
|
72
|
+
assert_match dn_regex, user["DN"] unless user["DN"].nil?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_print_user_entitlement
|
77
|
+
column_num=Array.new
|
78
|
+
@jpm_tracker.jpm_user_entitlement.values.map do |rec|
|
79
|
+
column_num.push(rec.each.size)
|
80
|
+
end
|
81
|
+
assert_equal 1, column_num.uniq!.size
|
82
|
+
$stdout = StringIO.new
|
83
|
+
@jpm_tracker.print_user.each
|
84
|
+
items=$stdout.string.split("\n")
|
85
|
+
items.each do |line|
|
86
|
+
assert_equal column_num[0]-1, line.count("|")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_save_jpm_user_map!
|
91
|
+
@jpm_tracker.send(:save!, File.dirname(__FILE__)+"/jpm_access_testfiles/jpm_access_user_map_test.txt")
|
92
|
+
line_count=0
|
93
|
+
File.open(File.dirname(__FILE__)+"/jpm_access_testfiles/jpm_access_user_map_test.txt", 'r').each_line do |line|
|
94
|
+
if line_count==0
|
95
|
+
assert_match (/\# local Jpm for Securitites to AD user map file created by the .+ class .+ method at: .+/), line
|
96
|
+
else
|
97
|
+
user_id=line.split("|")[0]
|
98
|
+
dn=line.split("|")[1].nil? ? dn="" : dn=line.split("|")[1].strip
|
99
|
+
assert_equal @jpm_tracker.jpm_user_entitlement[line_count]["User ID"].upcase, user_id
|
100
|
+
if dn.empty?
|
101
|
+
assert_nil @jpm_tracker.jpm_user_entitlement[line_count]["DN"]
|
102
|
+
else
|
103
|
+
assert_equal @jpm_tracker.jpm_user_entitlement[line_count]["DN"], dn
|
104
|
+
end
|
105
|
+
end
|
106
|
+
line_count+=1
|
107
|
+
end
|
108
|
+
File.delete(File.dirname(__FILE__)+"/jpm_access_testfiles/jpm_access_user_map_test.txt")
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_jpm_search_by_dn
|
112
|
+
index=0
|
113
|
+
File.open(@jpm_tracker.file_jpm_user_map, 'r').each_line do |line|
|
114
|
+
if index>0
|
115
|
+
dn=line.split("|")[1].nil? ? dn="" : dn=line.split("|")[1].strip
|
116
|
+
assert_equal dn, @jpm_tracker.send(:search_by_dn, dn)['DN'] unless dn.empty?
|
117
|
+
end
|
118
|
+
index=index+1
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "ucert"
|
3
|
+
|
4
|
+
class TestMadison535Tracker < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@madison535_tracker = Ucert::Madison535Tracker.new(:verbose=>false)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_instance_initialize_success
|
11
|
+
refute_nil @madison535_tracker.madison535_user_access_report
|
12
|
+
refute_nil @madison535_tracker.madison535_user_access_report_2
|
13
|
+
refute_nil @madison535_tracker.file_madison535_user_map
|
14
|
+
refute_nil @madison535_tracker.madison535_2_ad_user
|
15
|
+
refute_nil @madison535_tracker.madison535_user_access
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_parse_madison535_user_access_report_method
|
19
|
+
@madison535_user_access_repot_test=@madison535_tracker.send(:parse_madison535_user_access_report, File.dirname(__FILE__)+"/madison535_testfiles/535madison_bldg_pass_Test.xlsx")
|
20
|
+
users=Array.new
|
21
|
+
for ii in 1..3 do
|
22
|
+
users.push(["CHINA MERCHANTS BANK","#{ii}","test#{ii}_firstname","test#{ii}_lastname"])
|
23
|
+
end
|
24
|
+
ii=0
|
25
|
+
@madison535_user_access_repot_test.each do |index, content|
|
26
|
+
assert_equal users[ii], content.values.to_a
|
27
|
+
ii+=1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_parse_madison535_user_access_report_2_method
|
32
|
+
@madison535_tracker.send(:parse_madison535_user_access_report_2, File.dirname(__FILE__)+"/madison535_testfiles/535madison_bldg_pass_2_Test.xlsx")
|
33
|
+
user1={"First Name"=>"test1_firstname","Last Name"=>"test1_lastname", "Card #"=>"1", "Clearance1"=>"", "Clearance2"=>"Main Door - 24x7x365", "Clearance3"=>"", "Clearance4"=>"Trading Room - 24x7x365", "Clearance5"=>"", "Disabled"=>"no","Company"=>"CMBNY", "DN"=>nil}
|
34
|
+
user2={"First Name"=>"test2_firstname","Last Name"=>"test2_lastname", "Card #"=>"1", "Clearance1"=>"IT Room Door - 24x7x365", "Clearance2"=>"", "Clearance3"=>"Security Room - 24x7x365", "Clearance4"=>"", "Clearance5"=>"FL-23 File Room Access", "Disabled"=>"yes","Company"=>"CMBNY", "DN"=>nil}
|
35
|
+
user3={"First Name"=>"test3_firstname","Last Name"=>"test3_lastname", "Card #"=>"2", "Clearance1"=>"", "Clearance2"=>"", "Clearance3"=>"", "Clearance4"=>"", "Clearance5"=>"", "Disabled"=>"yes","Company"=>"CMBNY", "DN"=>nil}
|
36
|
+
last_index=@madison535_tracker.madison535_user_access.size
|
37
|
+
assert_equal user3, @madison535_tracker.madison535_user_access[last_index]
|
38
|
+
assert_equal user2, @madison535_tracker.madison535_user_access[last_index-1]
|
39
|
+
#user1 would be overwritten by user2 since they have same card number.
|
40
|
+
refute_equal user1, @madison535_tracker.madison535_user_access[last_index-2]
|
41
|
+
end
|
42
|
+
|
43
|
+
#function is not in use, but mutiple indexes map to one DN, which would cause test fail
|
44
|
+
def test_dn_2_index
|
45
|
+
=begin
|
46
|
+
FileUtils.cp_r(File.dirname(__FILE__)+"/../data/madison535/madison535_user_map.txt", File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt")
|
47
|
+
line_cnt=1
|
48
|
+
File.open(File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt", 'r').each_line do |line|
|
49
|
+
if line_cnt>1
|
50
|
+
dn=line.split("|")[1].nil? ? dn="" : dn=line.split("|")[1].strip
|
51
|
+
assert_equal line_cnt-1, @madison535_tracker.send(:dn_2_index, dn) unless dn.empty?
|
52
|
+
end
|
53
|
+
line_cnt+=1
|
54
|
+
end
|
55
|
+
File.delete(File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt")
|
56
|
+
=end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_card_num_2_index
|
60
|
+
FileUtils.cp_r(File.dirname(__FILE__)+"/../data/madison535/madison535_user_map.txt", File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt")
|
61
|
+
line_cnt=1
|
62
|
+
File.open(File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt", 'r').each_line do |line|
|
63
|
+
if line_cnt>1
|
64
|
+
card_num=line.split("|")[0].strip
|
65
|
+
assert_equal line_cnt-1, @madison535_tracker.send(:card_num_2_index, card_num)
|
66
|
+
end
|
67
|
+
line_cnt+=1
|
68
|
+
end
|
69
|
+
File.delete(File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt")
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_insert_dn
|
73
|
+
@madison535_tracker.madison535_user_access.each do |index, user|
|
74
|
+
dn_regex=/\ACN=.+\,DC=ny,DC=cmbchina,DC=com\z/
|
75
|
+
assert_match dn_regex, user["DN"] unless user["DN"].nil?
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_print_user_access
|
80
|
+
column_num=Array.new
|
81
|
+
@madison535_tracker.madison535_user_access.values.map do |rec|
|
82
|
+
column_num.push(rec.each.size)
|
83
|
+
end
|
84
|
+
column_num.uniq!
|
85
|
+
$stdout = StringIO.new
|
86
|
+
@madison535_tracker.print_user.each
|
87
|
+
items=$stdout.string.split("\n")
|
88
|
+
items.each do |line|
|
89
|
+
assert_includes column_num, line.count("|")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_save_madison535_user_map!
|
94
|
+
@madison535_tracker.send(:save!, File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt")
|
95
|
+
line_count=0
|
96
|
+
File.open(File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt", 'r').each_line do |line|
|
97
|
+
if line_count==0
|
98
|
+
assert_match (/\# Madison535 to AD user map file created by the .+ class .+ method at: .+/), line
|
99
|
+
else
|
100
|
+
card_num=line.split("|")[0]
|
101
|
+
dn=line.split("|")[1].nil? ? dn="" : dn=line.split("|")[1].strip
|
102
|
+
assert_equal @madison535_tracker.madison535_user_access[line_count]["Card #"].upcase, card_num
|
103
|
+
if dn.empty?
|
104
|
+
assert_nil @madison535_tracker.madison535_user_access[line_count]["DN"]
|
105
|
+
else
|
106
|
+
assert_equal @madison535_tracker.madison535_user_access[line_count]["DN"], dn
|
107
|
+
end
|
108
|
+
end
|
109
|
+
line_count+=1
|
110
|
+
end
|
111
|
+
File.delete(File.dirname(__FILE__)+"/madison535_testfiles/madison535_user_map_test.txt")
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_madison535_search_by_dn
|
115
|
+
index=0
|
116
|
+
File.open(@madison535_tracker.file_madison535_user_map, 'r').each_line do |line|
|
117
|
+
if index>0
|
118
|
+
dn=line.split("|")[1].nil? ? dn="" : dn=line.split("|")[1].strip
|
119
|
+
assert_equal dn, @madison535_tracker.send(:search_by_dn, dn)['DN'] unless dn.empty?
|
120
|
+
end
|
121
|
+
index=index+1
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|