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,151 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "ucert"
|
3
|
+
|
4
|
+
class TestT24Tracker < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@t24_tracker = Ucert::T24Tracker.new(:verbose=>false)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_instance_initialize_success
|
11
|
+
refute_nil @t24_tracker.t24_user_entitlement_report
|
12
|
+
refute_nil @t24_tracker.t24_group_entitlement_report
|
13
|
+
refute_nil @t24_tracker.file_user_map
|
14
|
+
refute_nil @t24_tracker.t24_user_entitlement
|
15
|
+
refute_nil @t24_tracker.t24_group_entitlement
|
16
|
+
refute_nil @t24_tracker.t24_2_ad_user
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_parse_t24_user_report
|
20
|
+
@test_t24_entitlement=@t24_tracker.send(:parse_t24_user_report, File.dirname(__FILE__)+"/t24_testfiles/T24_User_Rpt_Test.csv")
|
21
|
+
titles=File.open(File.dirname(__FILE__)+"/t24_testfiles/T24_User_Rpt_Test.csv", 'r').first.split(",").map {|x| x.gsub("\"","").gsub(/\n/, "")}
|
22
|
+
user_group=Hash.new
|
23
|
+
for i in 1..3
|
24
|
+
user_group[i]=Hash.new
|
25
|
+
j=1
|
26
|
+
titles.each do |title|
|
27
|
+
title.tr!('@','')
|
28
|
+
if title=="APPLICATION"
|
29
|
+
q=j+1
|
30
|
+
user_group[i][title]={"TEST#{i}-#{j}"=>"TEST#{i}-#{q}"}
|
31
|
+
j+=1
|
32
|
+
elsif title=="FUNCTION"
|
33
|
+
j+=1
|
34
|
+
elsif title=="TIME.LAST.SIGN.ON"
|
35
|
+
else
|
36
|
+
user_group[i][title]="TEST#{i}-#{j}"
|
37
|
+
j+=1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
k=1
|
41
|
+
flag=false
|
42
|
+
while k<i do
|
43
|
+
key=user_group[i]["APPLICATION"].keys[0]+"-"+k.to_s
|
44
|
+
user_group[i]["APPLICATION"][key]=key
|
45
|
+
k+=1
|
46
|
+
flag=true
|
47
|
+
end
|
48
|
+
if flag
|
49
|
+
user_group[i]["GROUP"]=["@TEST#{i}-3"]
|
50
|
+
user_group[i]["APPLICATION"].delete(user_group[i]["APPLICATION"].first[0])
|
51
|
+
end
|
52
|
+
user_group[i].delete(user_group[i].first[0])
|
53
|
+
user_group[i]["ID"]="TEST#{i}-1"
|
54
|
+
end
|
55
|
+
assert_equal user_group, @test_t24_entitlement
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_parse_t24_group_report
|
59
|
+
@test_t24_entitlement=@t24_tracker.send(:parse_t24_group_report, File.dirname(__FILE__)+"/t24_testfiles/T24_Grp_Rpt_Test.csv")
|
60
|
+
titles=["ID","DESCRIPTION","APPLICATION"]
|
61
|
+
test_group=Hash.new
|
62
|
+
for i in 1..3
|
63
|
+
test_group[i]=Hash.new
|
64
|
+
j=1
|
65
|
+
titles.each do |title|
|
66
|
+
if title=="APPLICATION"
|
67
|
+
test_group[i]["APPLICATION"]=Hash.new
|
68
|
+
application_name="TEST#{i}-#{j}"
|
69
|
+
test_group[i]["APPLICATION"][application_name]=Hash.new
|
70
|
+
j+=1
|
71
|
+
test_group[i]["APPLICATION"][application_name]["VERSION"]="TEST#{i}-#{j}"
|
72
|
+
j+=1
|
73
|
+
test_group[i]["APPLICATION"][application_name]["FUNCTION"]="TEST#{i}-#{j}"
|
74
|
+
else
|
75
|
+
test_group[i][title]="TEST#{i}-#{j}"
|
76
|
+
end
|
77
|
+
j+=1
|
78
|
+
end
|
79
|
+
k=1
|
80
|
+
while k<i do
|
81
|
+
application_name=test_group[i]["APPLICATION"].keys[0]+"-"+k.to_s
|
82
|
+
test_group[i]["APPLICATION"][application_name]=Hash.new
|
83
|
+
test_group[i]["APPLICATION"][application_name]["VERSION"]=""
|
84
|
+
test_group[i]["APPLICATION"][application_name]["FUNCTION"]=application_name
|
85
|
+
k+=1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
assert_equal test_group, @test_t24_entitlement
|
89
|
+
refute_nil @test_t24_entitlement
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_insert_dn
|
93
|
+
@t24_tracker.t24_user_entitlement.each do |index, user|
|
94
|
+
dn_regex=/\ACN=.+\,OU=.+\,DC=ny,DC=cmbchina,DC=com\z/
|
95
|
+
assert_match dn_regex, user["DN"] unless user["DN"].nil?
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_save_t24_user_map!
|
100
|
+
@t24_tracker.send(:save!, File.dirname(__FILE__)+"/t24_testfiles/t24_user_map_test.txt")
|
101
|
+
line_count=0
|
102
|
+
File.open(File.dirname(__FILE__)+"/t24_testfiles/t24_user_map_test.txt", 'r').each_line do |line|
|
103
|
+
if line_count==0
|
104
|
+
assert_match (/\# local T24 to AD user map file created by the .+ class .+ method at: .+/), line
|
105
|
+
else
|
106
|
+
user_id=line.split(":")[0]
|
107
|
+
user_name=line.split(":")[1].split("|")[0]
|
108
|
+
dn=line.split(":")[1].split("|")[1].nil? ? dn="" : dn=line.split(":")[1].split("|")[1].strip
|
109
|
+
assert_equal @t24_tracker.t24_user_entitlement[line_count]["USER.NAME"].upcase, user_name
|
110
|
+
assert_equal @t24_tracker.t24_user_entitlement[line_count]["ID"].upcase, user_id
|
111
|
+
if dn.empty?
|
112
|
+
assert_nil @t24_tracker.t24_user_entitlement[line_count]["DN"]
|
113
|
+
else
|
114
|
+
assert_equal @t24_tracker.t24_user_entitlement[line_count]["DN"], dn
|
115
|
+
end
|
116
|
+
end
|
117
|
+
line_count+=1
|
118
|
+
end
|
119
|
+
File.delete(File.dirname(__FILE__)+"/t24_testfiles/t24_user_map_test.txt")
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_t24_search_by_dn
|
123
|
+
index=0
|
124
|
+
File.open(@t24_tracker.file_user_map, 'r').each_line do |line|
|
125
|
+
if index>0
|
126
|
+
line.split("|")[1].nil? ? dn="" : dn=line.split("|")[1].strip
|
127
|
+
assert_equal dn, @t24_tracker.send(:search_by_dn, dn)['DN'] unless dn.empty?
|
128
|
+
end
|
129
|
+
index=index+1
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_print_user_entitlement
|
134
|
+
$stdout = StringIO.new
|
135
|
+
@t24_tracker.print_user.each
|
136
|
+
items=$stdout.string.split("\n")
|
137
|
+
items.each do |line|
|
138
|
+
assert_equal 6, line.count("|")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_print_group_entitlement
|
143
|
+
$stdout = StringIO.new
|
144
|
+
@t24_tracker.print_group.each
|
145
|
+
items=$stdout.string.split("\n")
|
146
|
+
items.each do |line|
|
147
|
+
assert_equal 2, line.count("|")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
data/test/test_utils.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "ucert"
|
3
|
+
|
4
|
+
class TestClass
|
5
|
+
include Ucert::Utils
|
6
|
+
end
|
7
|
+
|
8
|
+
class TestUtils < Minitest::Test
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@test_instance = TestClass.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_file_2_list
|
15
|
+
test_array=["Test1","Test2","Test3","Test4","Test5"]
|
16
|
+
assert_equal test_array, @test_instance.file_2_list(File.dirname(__FILE__)+"/utils_testfiles/file2list_test.txt")
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_search_ad
|
20
|
+
test_dn="CN=HOAuditor,OU=Disabled Users,OU=New York Branch,DC=ny,DC=cmbchina,DC=com"
|
21
|
+
assert_equal test_dn, @test_instance.search_ad("HOAuditor")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_load_known_user_map_from_file
|
25
|
+
test_hash={"1"=>"test1", "2"=>"test2", "3"=>"test3"}
|
26
|
+
assert_equal test_hash, @test_instance.load_known_user_map_from_file(File.dirname(__FILE__)+"/utils_testfiles/load_know_user_map_testfile.txt")
|
27
|
+
end
|
28
|
+
|
29
|
+
# ip =~ /\d+\.\d+\.\d+.\d+/ return 0 in method for a valid ip
|
30
|
+
def test_is_ip?
|
31
|
+
test_ip=["1.1.1.1","192.1.10.1","00.00.0.1","999.0.1.3","11.00.1.","19216818","a.b.c.1","1.1.1.1.1"]
|
32
|
+
assert @test_instance.is_ip?(test_ip[0])
|
33
|
+
assert @test_instance.is_ip?(test_ip[1])
|
34
|
+
refute @test_instance.is_ip?(test_ip[2])
|
35
|
+
refute @test_instance.is_ip?(test_ip[3])
|
36
|
+
refute @test_instance.is_ip?(test_ip[4])
|
37
|
+
refute @test_instance.is_ip?(test_ip[5])
|
38
|
+
refute @test_instance.is_ip?(test_ip[6])
|
39
|
+
refute @test_instance.is_ip?(test_ip[7])
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_nslookup
|
43
|
+
assert @test_instance.nslookup("www.ruby-lang.org")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "ucert"
|
3
|
+
|
4
|
+
class TestVpnTracker < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@vpn_tracker = Ucert::VpnTracker.new(:verbose=>false)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_instance_initialize_success
|
11
|
+
refute_nil @vpn_tracker.vpn_user_entitlement
|
12
|
+
end
|
13
|
+
|
14
|
+
#user CN=Sherry's department is "Gompliance" instead of "Compliance", the typo caused the test fail.
|
15
|
+
def test_parse_vpn_user_info
|
16
|
+
=begin
|
17
|
+
department_catagory=["IT","FI","Banking Operations","Management","Compliance","Corporate Banking US Group","Corporate Banking China Group","TransactionBanking","Treasury","Risk Management","Credit Products Group","Finance","SPD","PB","Human Resource","CPG","General Office"]
|
18
|
+
@test_vpn_entitlement=@vpn_tracker.send(:parse_vpn_user_info)
|
19
|
+
cout=1
|
20
|
+
@test_vpn_entitlement.each do |index, people|
|
21
|
+
assert_equal true, people.has_key?("CN")
|
22
|
+
user_cn=people["CN"]
|
23
|
+
puts "checking index:"+cout.to_s+" CN:"+user_cn
|
24
|
+
puts people
|
25
|
+
people.each do |key, value|
|
26
|
+
if key=="department"
|
27
|
+
assert department_catagory.include? value
|
28
|
+
elsif key=="VPN Class"
|
29
|
+
assert_match (/\Aclass_\d\z/), value
|
30
|
+
elsif key=="DN"
|
31
|
+
assert_match (/\A#{user_cn}\,OU=Users,OU=.+\,DC=ny,DC=cmbchina,DC=com\z/), value
|
32
|
+
else
|
33
|
+
refute_nil value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
cout=cout+1
|
37
|
+
end
|
38
|
+
=end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_print_user_entitlement
|
42
|
+
column_num=Array.new
|
43
|
+
@vpn_tracker.vpn_user_entitlement.values.each do |rec|
|
44
|
+
column_num.push(rec.each.size)
|
45
|
+
end
|
46
|
+
assert_equal 1, column_num.uniq!.size
|
47
|
+
$stdout = StringIO.new
|
48
|
+
@vpn_tracker.print_user
|
49
|
+
items=$stdout.string.split("\n")
|
50
|
+
items.each do |line|
|
51
|
+
assert_match (/\A.+\|(.*\|){#{column_num[0]-1}}\z/), line
|
52
|
+
assert_equal column_num[0], line.count("|")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "ucert"
|
3
|
+
|
4
|
+
class TestWmsTracker < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@wms_tracker = Ucert::WmsTracker.new(:verbose=>false)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_instance_initialize_success
|
11
|
+
refute_nil @wms_tracker.wms_user_report
|
12
|
+
refute_nil @wms_tracker.wms_role_report
|
13
|
+
refute_nil @wms_tracker.file_user_map
|
14
|
+
refute_nil @wms_tracker.wms_2_ad_user
|
15
|
+
refute_nil @wms_tracker.wms_user_entitlement
|
16
|
+
refute_nil @wms_tracker.wms_role_entitlement
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_parse_wms_user_report_method
|
20
|
+
@test_user_entitlement=@wms_tracker.send(:parse_wms_user_report, File.dirname(__FILE__)+"/wms_testfiles/user_rpt_test.txt")
|
21
|
+
test_group=Hash.new
|
22
|
+
test_group[1]={"USERID"=>"test","USERNAME"=>"测试员","STATUS"=>"1","ORGNAME"=>"全行"}
|
23
|
+
test_group[2]={"USERID"=>"admin","USERNAME"=>"管理员","STATUS"=>"1","ORGNAME"=>"纽约分行信息技术部"}
|
24
|
+
test_group[3]={"USERID"=>"developer","USERNAME"=>"开发员","STATUS"=>"0","ORGNAME"=>"纽约分行风险管理部"}
|
25
|
+
test_group[1]["ROLEID"]={"0000"=>true}
|
26
|
+
test_group[2]["ROLEID"]={"0001"=>true,"0002"=>true,"0003"=>true}
|
27
|
+
test_group[3]["ROLEID"]={"0004"=>true}
|
28
|
+
for i in 1..3
|
29
|
+
assert_equal test_group[i], @test_user_entitlement[i]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_parse_wms_role_report_method
|
34
|
+
@test_role_entitlement=@wms_tracker.send(:parse_wms_role_report, File.dirname(__FILE__)+"/wms_testfiles/role_rpt_test.txt")
|
35
|
+
test_group=Hash.new
|
36
|
+
test_group["0000"]={"ROLENAME"=>"超级测试员"}
|
37
|
+
test_group["0001"]={"ROLENAME"=>"测试管理员"}
|
38
|
+
test_group["0002"]={"ROLENAME"=>"一般测试员"}
|
39
|
+
test_group["0000"]["PRV"]=[{"PRVID"=>"0000_SA1","PRVNAME"=>"Super Admin1","URL"=>"/ad1"},{"PRVID"=>"0000_SA2","PRVNAME"=>"Super Admin2","URL"=>"/ad2"}]
|
40
|
+
test_group["0001"]["PRV"]=[{"PRVID"=>"0000_SA2","PRVNAME"=>"Super Admin2","URL"=>"/ad2"},{"PRVID"=>"0001_TA1","PRVNAME"=>"Test Admin1","URL"=>"/ta1"}]
|
41
|
+
test_group["0002"]["PRV"]=[{"PRVID"=>"0002_TA2","PRVNAME"=>"Test Admin2","URL"=>"/ta2"}]
|
42
|
+
for i in ["0000","0001","0002"]
|
43
|
+
assert_equal test_group[i], @test_role_entitlement[i]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_insert_dn
|
48
|
+
@wms_tracker.wms_user_entitlement.each do |index, user|
|
49
|
+
dn_regex=/\ACN=.+\,OU=.+\,DC=ny,DC=cmbchina,DC=com\z/
|
50
|
+
assert_match dn_regex, user["DN"] unless user["DN"].nil?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_print_user_entitlement
|
55
|
+
$stdout = StringIO.new
|
56
|
+
@wms_tracker.print_user
|
57
|
+
items=$stdout.string.split("\n")
|
58
|
+
items.each do |line|
|
59
|
+
if line.include?("CN=")
|
60
|
+
assert_match (/\A.+\|.+\|(0|1)\|.+\|\{.+\}\|CN=[a-zA-Z\s]+,OU=[a-zA-Z\s]+,.*DC=ny,DC=cmbchina,DC=com\|\z/), line
|
61
|
+
else
|
62
|
+
assert_match (/\A.+\|.+\|(0|1)\|.+\|\{.+\}\|\|\z/), line
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_print_user_role
|
68
|
+
$stdout = StringIO.new
|
69
|
+
@wms_tracker.print_role
|
70
|
+
items=$stdout.string.split("\n")
|
71
|
+
items.each do |line|
|
72
|
+
assert_match (/\A.+\|.+\|\[\{(\".+\"\=\>.+\,)*\".+\"\=\>.+\}\]\z/), line
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_save_wms_user_map!
|
77
|
+
@wms_tracker.send(:save!, File.dirname(__FILE__)+"/wms_testfiles/wms_user_map_test.txt")
|
78
|
+
line_count=0
|
79
|
+
File.open(File.dirname(__FILE__)+"/wms_testfiles/wms_user_map_test.txt", 'r').each_line do |line|
|
80
|
+
if line_count==0
|
81
|
+
assert_match (/\# local Wms to AD user map file created by the .+ class .+ method at: .+/), line
|
82
|
+
else
|
83
|
+
user_name=line.split(":")[0]
|
84
|
+
user_id=line.split(":")[1].split("|")[0]
|
85
|
+
dn=line.split(":")[1].split("|")[1].nil? ? dn="" : dn=line.split(":")[1].split("|")[1].strip
|
86
|
+
assert_equal @wms_tracker.wms_user_entitlement[line_count]["USERNAME"].upcase, user_name
|
87
|
+
assert_equal @wms_tracker.wms_user_entitlement[line_count]["USERID"].upcase, user_id
|
88
|
+
if dn.empty?
|
89
|
+
assert_nil @wms_tracker.wms_user_entitlement[line_count]["DN"]
|
90
|
+
else
|
91
|
+
assert_equal @wms_tracker.wms_user_entitlement[line_count]["DN"], dn
|
92
|
+
end
|
93
|
+
end
|
94
|
+
line_count+=1
|
95
|
+
end
|
96
|
+
File.delete(File.dirname(__FILE__)+"/wms_testfiles/wms_user_map_test.txt")
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_wms_search_by_dn
|
100
|
+
index=0
|
101
|
+
File.open(@wms_tracker.file_user_map, 'r').each_line do |line|
|
102
|
+
if index>0
|
103
|
+
line.split("|")[1].nil? ? dn="" : dn=line.split("|")[1].strip
|
104
|
+
assert_equal dn, @wms_tracker.send(:search_by_dn, dn)['DN'] unless dn.empty?
|
105
|
+
end
|
106
|
+
index=index+1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "ucert"
|
3
|
+
|
4
|
+
class TestYstTracker < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@yst_tracker = Ucert::YstTracker.new(:verbose=>false)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_instance_initialize_success
|
11
|
+
refute_nil @yst_tracker.yst_user_report
|
12
|
+
refute_nil @yst_tracker.yst_org_report
|
13
|
+
refute_nil @yst_tracker.file_user_map
|
14
|
+
refute_nil @yst_tracker.yst_2_ad_user
|
15
|
+
refute_nil @yst_tracker.yst_user_entitlement
|
16
|
+
refute_nil @yst_tracker.yst_org_entitlement
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_parse_yst_user_report_method
|
20
|
+
@test_user_entitlement=@yst_tracker.send(:parse_yst_user_report, File.dirname(__FILE__)+"/yst_testfiles/YiShiTong_User_Test.csv")
|
21
|
+
line_cnt=0
|
22
|
+
File.open(File.dirname(__FILE__)+"/yst_testfiles/YiShiTong_User_Test.csv",'r:gb18030:UTF-8').each do |line|
|
23
|
+
if line_cnt==0
|
24
|
+
@title=line.chomp.split(",")
|
25
|
+
else
|
26
|
+
user=line.chomp.split(",").map {|x| x.gsub(/(\s|\")/,"")}
|
27
|
+
assert_equal @title.size, @test_user_entitlement.values[line_cnt-1].size
|
28
|
+
assert_equal user, @test_user_entitlement.values[line_cnt-1].values
|
29
|
+
end
|
30
|
+
line_cnt+=1
|
31
|
+
end
|
32
|
+
assert_equal line_cnt-1, @test_user_entitlement.size
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_parse_yst_org_report_method
|
36
|
+
@test_org_entitlement=@yst_tracker.send(:parse_yst_org_report,File.dirname(__FILE__)+"/yst_testfiles/YiShiTong_Org_Test.csv")
|
37
|
+
line_cnt=0
|
38
|
+
f=File.open( File.dirname(__FILE__)+"/yst_testfiles/YiShiTong_Org_Test.csv",'r:gb18030:UTF-8')
|
39
|
+
f.each do |line|
|
40
|
+
if line_cnt==0
|
41
|
+
@title=line.chomp.split(",")
|
42
|
+
else
|
43
|
+
org=line.chomp.split(",").map {|x| x.gsub(/(\s|\")/,"")}
|
44
|
+
assert_equal @title.size, @test_org_entitlement.values[line_cnt-1].size
|
45
|
+
assert_equal org, @test_org_entitlement.values[line_cnt-1].values
|
46
|
+
end
|
47
|
+
line_cnt+=1
|
48
|
+
end
|
49
|
+
assert_equal line_cnt-1, @test_org_entitlement.size
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_insert_dn
|
53
|
+
@yst_tracker.yst_user_entitlement.each do |index, user|
|
54
|
+
dn_regex=/\ACN=.+\,OU=.+\,DC=ny,DC=cmbchina,DC=com\z/
|
55
|
+
assert_match dn_regex, user["DN"] unless user["DN"].nil?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_save_yst_user_map!
|
60
|
+
@yst_tracker.send(:save!, File.dirname(__FILE__)+"/yst_testfiles/yst_user_map_test.txt")
|
61
|
+
line_count=0
|
62
|
+
File.open(File.dirname(__FILE__)+"/yst_testfiles/yst_user_map_test.txt", 'r').each_line do |line|
|
63
|
+
if line_count==0
|
64
|
+
assert_match (/\# local Yst to AD user map file created by the .+ class .+ method at: .+/), line
|
65
|
+
else
|
66
|
+
user_name=line.split(":")[0]
|
67
|
+
email=line.split(":")[1].split("|")[0]
|
68
|
+
dn=line.split(":")[1].split("|")[1].nil? ? dn="" : dn=line.split(":")[1].split("|")[1].strip
|
69
|
+
assert_equal @yst_tracker.yst_user_entitlement[line_count]["USER_NAME"].upcase, user_name
|
70
|
+
assert_equal @yst_tracker.yst_user_entitlement[line_count]["EMAIL"].upcase, email
|
71
|
+
if dn.empty?
|
72
|
+
assert_nil @yst_tracker.yst_user_entitlement[line_count]["DN"]
|
73
|
+
else
|
74
|
+
assert_equal @yst_tracker.yst_user_entitlement[line_count]["DN"], dn
|
75
|
+
end
|
76
|
+
end
|
77
|
+
line_count+=1
|
78
|
+
end
|
79
|
+
File.delete(File.dirname(__FILE__)+"/yst_testfiles/yst_user_map_test.txt")
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_yst_search_by_dn
|
83
|
+
index=0
|
84
|
+
File.open(@yst_tracker.file_user_map, 'r').each_line do |line|
|
85
|
+
if index>0
|
86
|
+
line.split("|")[1].nil? ? dn="" : dn=line.split("|")[1].strip
|
87
|
+
assert_equal dn, @yst_tracker.send(:search_by_dn, dn)['DN'] unless dn.empty?
|
88
|
+
end
|
89
|
+
index=index+1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_yst_search_by_id
|
94
|
+
index=0
|
95
|
+
File.open(@yst_tracker.yst_user_report, 'r:gb18030:UTF-8').each_line do |line|
|
96
|
+
if index>0
|
97
|
+
id=line.split(",")[0].gsub('"', '')
|
98
|
+
assert_equal id, @yst_tracker.send(:search_by_id, id)['USER_ID']
|
99
|
+
end
|
100
|
+
index=index+1
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_yst_user_entitlement
|
105
|
+
column_num=Array.new
|
106
|
+
@yst_tracker.yst_user_entitlement.values.map do |rec|
|
107
|
+
column_num.push(rec.each.size)
|
108
|
+
end
|
109
|
+
assert_equal 1, column_num.uniq!.size
|
110
|
+
$stdout = StringIO.new
|
111
|
+
@yst_tracker.print_user.each
|
112
|
+
items=$stdout.string.split("\n")
|
113
|
+
items.each do |line|
|
114
|
+
assert_match (/\A.+\|(.*\|){#{column_num[0]-1}}\z/), line
|
115
|
+
assert_equal column_num[0], line.count("|")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_print_org_entitlement
|
120
|
+
column_num=Array.new
|
121
|
+
@yst_tracker.yst_org_entitlement.values.map do |rec|
|
122
|
+
column_num.push(rec.each.size)
|
123
|
+
end
|
124
|
+
assert_equal 1, column_num.uniq!.size
|
125
|
+
$stdout = StringIO.new
|
126
|
+
@yst_tracker.print_org.each
|
127
|
+
items=$stdout.string.split("\n")
|
128
|
+
items.each do |line|
|
129
|
+
assert_match (/\A.+\|(.*\|){#{column_num[0]-1}}\z/), line
|
130
|
+
assert_equal column_num[0], line.count("|")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|