rsutphin-cf_case_check 0.0.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.
- data/.gitignore +3 -0
- data/History.txt +3 -0
- data/Manifest.txt +26 -0
- data/README.txt +75 -0
- data/Rakefile +39 -0
- data/bin/cf_case_check +27 -0
- data/lib/case_check/coldfusion_source.rb +92 -0
- data/lib/case_check/commands.rb +103 -0
- data/lib/case_check/configuration.rb +46 -0
- data/lib/case_check/core-ext.rb +51 -0
- data/lib/case_check/reference.rb +63 -0
- data/lib/case_check/references/cfc.rb +47 -0
- data/lib/case_check/references/cfinclude.rb +20 -0
- data/lib/case_check/references/cfmodule.rb +48 -0
- data/lib/case_check/references/custom_tag.rb +50 -0
- data/lib/case_check.rb +60 -0
- data/spec/coldfusion_source_spec.rb +161 -0
- data/spec/commands_spec.rb +103 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/core_ext_spec.rb +72 -0
- data/spec/reference_spec.rb +52 -0
- data/spec/references/cfc_spec.rb +62 -0
- data/spec/references/cfinclude_spec.rb +66 -0
- data/spec/references/cfmodule_spec.rb +139 -0
- data/spec/references/custom_tag_spec.rb +143 -0
- data/spec/spec_helper.rb +37 -0
- metadata +100 -0
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe CaseCheck::Cfmodule::Name do
|
4
|
+
before(:each) do
|
5
|
+
# cfmodule with the name attribute searches in the custom tag directories
|
6
|
+
CaseCheck::CustomTag.directories = %w(/tmp/cfmod_specs/customtags)
|
7
|
+
CaseCheck::CustomTag.directories.each { |d| FileUtils.mkdir_p d }
|
8
|
+
|
9
|
+
@source = create_test_source("/tmp/cfmod_specs/theapp/quux.cfm", <<-CFM)
|
10
|
+
<cfsetting showdebugoutput="No" />
|
11
|
+
<cfif StructKeyExists(url,'protocol_id') AND StructKeyExists(url,'affiliate_id')>
|
12
|
+
<cfif session.theSecurityBaseObj.HasRoleAtAffiliate(Role='TeamLeader',AffiliateID=url.affiliate_id)>
|
13
|
+
<cfscript>
|
14
|
+
variables.protocolDao = CreateObject('component', '#application.pathToComponents#ProtocolDAO').init(datasource=application.db,
|
15
|
+
username=session.netid,
|
16
|
+
userIP=cgi.remote_addr);
|
17
|
+
|
18
|
+
variables.protocolDao.updateProtocol(protocolID=url.protocol_id, gcrcNumber=form.value);
|
19
|
+
</cfscript>
|
20
|
+
|
21
|
+
<cfoutput>#form.value#</cfoutput>
|
22
|
+
|
23
|
+
<cfmodule name="notis.ActivityLog" type="UPDATE GCRC" target="#url.protocol_id#">
|
24
|
+
</cfif>
|
25
|
+
</cfif>
|
26
|
+
CFM
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:each) do
|
30
|
+
FileUtils.rm_r '/tmp/cfmod_specs'
|
31
|
+
end
|
32
|
+
|
33
|
+
def actual_search
|
34
|
+
CaseCheck::Cfmodule.search(@source)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "has a human-readable name" do
|
38
|
+
actual_search.first.type_name.should == 'cfmodule with name'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "converts the dotted name into a slashed path" do
|
42
|
+
actual_search.first.expected_path.should == "notis/ActivityLog.cfm"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "resolves against the configured custom tag directories" do
|
46
|
+
expected_file = CaseCheck::CustomTag.directories.last + "/notis/ActivityLog.cfm"
|
47
|
+
touch expected_file
|
48
|
+
actual_search.first.resolved_to.should == expected_file
|
49
|
+
actual_search.first.resolution.should == :exact
|
50
|
+
end
|
51
|
+
|
52
|
+
it "does not resolve against subdirectories of the custom tag directories" do
|
53
|
+
expected_file = CaseCheck::CustomTag.directories.last + "/subdir/notis/ActivityLog.cfm"
|
54
|
+
touch expected_file
|
55
|
+
actual_search.first.resolved_to.should be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it "resolves case-insensitively against the configured custom tag directories" do
|
59
|
+
expected_file = CaseCheck::CustomTag.directories.last + "/notis/ActiviTYLog.cfm"
|
60
|
+
touch expected_file
|
61
|
+
actual_search.first.resolved_to.should == expected_file
|
62
|
+
actual_search.first.resolution.should == :case_insensitive
|
63
|
+
end
|
64
|
+
|
65
|
+
it "finds multiple cfmodule references" do
|
66
|
+
@source.content = <<-CFM
|
67
|
+
<cfmodule name="etc"/>
|
68
|
+
<cfmodule name="etal">
|
69
|
+
CFM
|
70
|
+
actual_search.should have(2).references
|
71
|
+
end
|
72
|
+
|
73
|
+
it "finds the cfmodule tag without regard to case" do
|
74
|
+
@source.content = <<-CFM
|
75
|
+
<cfMODule name="whatever">
|
76
|
+
CFM
|
77
|
+
actual_search.should have(1).reference
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe CaseCheck::Cfmodule::Template do
|
82
|
+
before(:each) do
|
83
|
+
@source = create_test_source("/tmp/cfmod_specs/theapp/quux.cfm", <<-CFM)
|
84
|
+
<CFOUTPUT>
|
85
|
+
<CFIF StoredQueryID GT 0>
|
86
|
+
storedqueryid : #StoredQueryID#
|
87
|
+
<CFModule Template="GetTheStoredStatement.cfm" datasource="#tablespace#" QueryName="#StoredQueryName#"
|
88
|
+
category="#querycategory#" sq_id=#StoredQueryID#>
|
89
|
+
<CFSET sqlstatement=TheStoredStatement>
|
90
|
+
</CFIF>
|
91
|
+
</CFOUTPUT>
|
92
|
+
CFM
|
93
|
+
end
|
94
|
+
|
95
|
+
after(:each) do
|
96
|
+
FileUtils.rm_r '/tmp/cfmod_specs'
|
97
|
+
end
|
98
|
+
|
99
|
+
def actual_search
|
100
|
+
CaseCheck::Cfmodule.search(@source)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "has a human-readable name" do
|
104
|
+
actual_search.first.type_name.should == 'cfmodule with template'
|
105
|
+
end
|
106
|
+
|
107
|
+
it "uses the template path as the path" do
|
108
|
+
actual_search.first.expected_path.should == "GetTheStoredStatement.cfm"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "resolves against file directory" do
|
112
|
+
expected_file = "/tmp/cfmod_specs/theapp/GetTheStoredStatement.cfm"
|
113
|
+
touch expected_file
|
114
|
+
actual_search.first.resolved_to.should == expected_file
|
115
|
+
actual_search.first.resolution.should == :exact
|
116
|
+
end
|
117
|
+
|
118
|
+
it "resolves against file directory case-insensitively" do
|
119
|
+
expected_file = "/tmp/cfmod_specs/theapp/GetTheSTOREDStatement.cfm"
|
120
|
+
touch expected_file
|
121
|
+
actual_search.first.resolved_to.should == expected_file
|
122
|
+
actual_search.first.resolution.should == :case_insensitive
|
123
|
+
end
|
124
|
+
|
125
|
+
it "finds multiple cfmodule references" do
|
126
|
+
@source.content = <<-CFM
|
127
|
+
<cfmodule template="etc"/>
|
128
|
+
<cfmodule template="etal">
|
129
|
+
CFM
|
130
|
+
actual_search.should have(2).references
|
131
|
+
end
|
132
|
+
|
133
|
+
it "finds the cfmodule tag without regard to case" do
|
134
|
+
@source.content = <<-CFM
|
135
|
+
<cfMODule template="whatever">
|
136
|
+
CFM
|
137
|
+
actual_search.should have(1).reference
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe CaseCheck::CustomTag do
|
4
|
+
before(:each) do
|
5
|
+
CaseCheck::CustomTag.directories = %w(/tmp/ctr_specs/customtags)
|
6
|
+
CaseCheck::CustomTag.directories.each { |d| FileUtils.mkdir_p d }
|
7
|
+
|
8
|
+
@source = create_test_source("/tmp/ctr_specs/theapp/quux.cfm", <<-CFM)
|
9
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
<title>Delete Risk Factors</title>
|
13
|
+
</head>
|
14
|
+
|
15
|
+
<body>
|
16
|
+
<CFQUERY NAME="DELETEPD" datasource=#application.db#>
|
17
|
+
UPDATE T_BRST_CIGALCHL
|
18
|
+
SET IS_DELETED = 'Y',
|
19
|
+
CHANGED_DATE = SYSDATE,
|
20
|
+
CHANGED_BY = '#session.netid#',
|
21
|
+
CHANGED_IP= '#cgi.remote_addr#'
|
22
|
+
WHERE PATIENT_ID = #URL.PATIENT_ID#
|
23
|
+
</CFQUERY>
|
24
|
+
|
25
|
+
<CF_ActivityLog activity_type="DELETE T_BRST_CIGALCHL" target="PATIENT_ID = #URL.PATIENT_ID#">
|
26
|
+
|
27
|
+
|
28
|
+
<CFOUTPUT>
|
29
|
+
<CF_DeleteRecordLog
|
30
|
+
PATIENT_ID=#URL.PATIENT_ID#
|
31
|
+
SSN="#URL.SSN#"
|
32
|
+
LAST_NAME="#URL.LAST_NAME#"
|
33
|
+
FIRST_NAME="#URL.FIRST_NAME#"
|
34
|
+
MIDDLE_NAME="#URL.MI#"
|
35
|
+
DESCRIPTION="Alcohol & Cigarettes"
|
36
|
+
TABLE_NAME="T_BRST_CIGALCHL"
|
37
|
+
REVERSED_CODE="PATIENT_ID = #URL.PATIENT_ID#"
|
38
|
+
>
|
39
|
+
</CFOUTPUT>
|
40
|
+
|
41
|
+
</body>
|
42
|
+
</html>
|
43
|
+
|
44
|
+
<SCRIPT LANGUAGE = "JavaScript1.2">
|
45
|
+
this.window.close();
|
46
|
+
</SCRIPT>
|
47
|
+
CFM
|
48
|
+
end
|
49
|
+
|
50
|
+
after(:each) do
|
51
|
+
FileUtils.rm_r '/tmp/ctr_specs'
|
52
|
+
end
|
53
|
+
|
54
|
+
def actual_search
|
55
|
+
CaseCheck::CustomTag.search(@source)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "has a human-readable name" do
|
59
|
+
actual_search.first.type_name.should == 'custom tag'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "translates lower case cf_ style" do
|
63
|
+
@source.content = <<-CFM
|
64
|
+
<div align="center"><cf_checkuserpermissions groups="Admin">
|
65
|
+
<input type="submit" name="submit" value="Save" >
|
66
|
+
</cf_checkuserpermissions>
|
67
|
+
</div>
|
68
|
+
CFM
|
69
|
+
|
70
|
+
actual_search.should have(1).reference
|
71
|
+
actual_search.first.expected_path.should == "checkuserpermissions.cfm"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "translates upper case CF_ style" do
|
75
|
+
@source.content = %q(<CF_ActivityLog activity_type="INSERT T_BRST_INSURANCE_SELECT" target="INSURANCE_ID=#QID.ID#">)
|
76
|
+
|
77
|
+
actual_search.should have(1).reference
|
78
|
+
actual_search.first.expected_path.should == "ActivityLog.cfm"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "terminates correctly for self-closing tags" do
|
82
|
+
@source.content = %q(<cf_abc/>and then some)
|
83
|
+
actual_search.first.text.should == "cf_abc"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "finds multiple refs in a single body" do
|
87
|
+
actual_search.should have(2).references
|
88
|
+
actual_search.first.expected_path.should == "ActivityLog.cfm"
|
89
|
+
actual_search.last.expected_path.should == "DeleteRecordLog.cfm"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "records the line number for each match" do
|
93
|
+
actual_search.should have(2).references
|
94
|
+
actual_search.first.line.should == 17
|
95
|
+
actual_search.last.line.should == 21
|
96
|
+
end
|
97
|
+
|
98
|
+
it "records the text for each match" do
|
99
|
+
actual_search.should have(2).references
|
100
|
+
actual_search.first.text.should == "CF_ActivityLog"
|
101
|
+
actual_search.last.text.should == "CF_DeleteRecordLog"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "resolves nothing if file not found" do
|
105
|
+
actual_search.first.resolved_to.should be_nil
|
106
|
+
actual_search.first.resolution.should be_nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it "resolves an exactly matching file in the same directory as the source if it exists" do
|
110
|
+
expected_file = "/tmp/ctr_specs/theapp/ActivityLog.cfm"
|
111
|
+
FileUtils.touch expected_file
|
112
|
+
actual_search.first.resolved_to.should == expected_file
|
113
|
+
actual_search.first.resolution.should == :exact
|
114
|
+
end
|
115
|
+
|
116
|
+
it "resolves the case-insensitive equivalent in the same directory as the source if it exists" do
|
117
|
+
expected_file = "/tmp/ctr_specs/theapp/ActivityLOG.cfm"
|
118
|
+
FileUtils.touch expected_file
|
119
|
+
actual_search.first.resolved_to.should == expected_file
|
120
|
+
actual_search.first.resolution.should == :case_insensitive
|
121
|
+
end
|
122
|
+
|
123
|
+
it "resolves the exact file from one of the customtag directories if it exists" do
|
124
|
+
expected_file = CaseCheck::CustomTag.directories.last + "/ActivityLog.cfm"
|
125
|
+
FileUtils.touch expected_file
|
126
|
+
actual_search.first.resolved_to.should == expected_file
|
127
|
+
actual_search.first.resolution.should == :exact
|
128
|
+
end
|
129
|
+
|
130
|
+
it "resolves the case-insensitive equivalent from one of the customtag directories if it exists" do
|
131
|
+
expected_file = CaseCheck::CustomTag.directories.last + "/activitylog.cFM"
|
132
|
+
FileUtils.touch expected_file
|
133
|
+
actual_search.first.resolved_to.should == expected_file
|
134
|
+
actual_search.first.resolution.should == :case_insensitive
|
135
|
+
end
|
136
|
+
|
137
|
+
it "resolves the file from a subdirectory of one of customtag directories" do
|
138
|
+
expected_file = CaseCheck::CustomTag.directories.last + "/pkg/foo/ActivityLog.cfm"
|
139
|
+
touch expected_file
|
140
|
+
actual_search.first.resolved_to.should == expected_file
|
141
|
+
actual_search.first.resolution.should == :exact
|
142
|
+
end
|
143
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path('../lib/case_check', File.dirname(__FILE__))
|
2
|
+
require 'fileutils'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
Spec::Runner.configure do |config|
|
6
|
+
config.before do
|
7
|
+
CaseCheck.status_stream = StringIO.new
|
8
|
+
end
|
9
|
+
|
10
|
+
config.after do
|
11
|
+
CaseCheck.status_stream = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
# == Mock Framework
|
15
|
+
#
|
16
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
17
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
18
|
+
#
|
19
|
+
# config.mock_with :mocha
|
20
|
+
# config.mock_with :flexmock
|
21
|
+
# config.mock_with :rr
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_test_source(filename, content)
|
25
|
+
FileUtils.mkdir_p File.dirname(filename)
|
26
|
+
|
27
|
+
File.open(filename, 'w') do |f|
|
28
|
+
f.write content
|
29
|
+
end
|
30
|
+
|
31
|
+
CaseCheck::ColdfusionSource.create(filename)
|
32
|
+
end
|
33
|
+
|
34
|
+
def touch(filename)
|
35
|
+
FileUtils.mkdir_p File.dirname(filename)
|
36
|
+
FileUtils.touch filename
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rsutphin-cf_case_check
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rhett Sutphin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-14 00:00:00 -08:00
|
13
|
+
default_executable: cf_case_check
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: bones
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 2.1.0
|
32
|
+
version:
|
33
|
+
description: A utility which walks a ColdFusion application's source and determines which includes, custom tags, etc, will not work with a case-sensitive filesystem
|
34
|
+
email: rhett@detailedbalance.net
|
35
|
+
executables:
|
36
|
+
- cf_case_check
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files:
|
40
|
+
- History.txt
|
41
|
+
- README.txt
|
42
|
+
- bin/cf_case_check
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- History.txt
|
46
|
+
- Manifest.txt
|
47
|
+
- README.txt
|
48
|
+
- Rakefile
|
49
|
+
- bin/cf_case_check
|
50
|
+
- lib/case_check.rb
|
51
|
+
- lib/case_check/coldfusion_source.rb
|
52
|
+
- lib/case_check/commands.rb
|
53
|
+
- lib/case_check/configuration.rb
|
54
|
+
- lib/case_check/core-ext.rb
|
55
|
+
- lib/case_check/reference.rb
|
56
|
+
- lib/case_check/references/cfc.rb
|
57
|
+
- lib/case_check/references/cfinclude.rb
|
58
|
+
- lib/case_check/references/cfmodule.rb
|
59
|
+
- lib/case_check/references/custom_tag.rb
|
60
|
+
- spec/coldfusion_source_spec.rb
|
61
|
+
- spec/commands_spec.rb
|
62
|
+
- spec/configuration_spec.rb
|
63
|
+
- spec/core_ext_spec.rb
|
64
|
+
- spec/reference_spec.rb
|
65
|
+
- spec/references/cfc_spec.rb
|
66
|
+
- spec/references/cfinclude_spec.rb
|
67
|
+
- spec/references/cfmodule_spec.rb
|
68
|
+
- spec/references/custom_tag_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: http://github.com/rsutphin/cf_case_check
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options:
|
74
|
+
- --main
|
75
|
+
- README.txt
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
version:
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
version:
|
90
|
+
requirements: []
|
91
|
+
|
92
|
+
rubyforge_project: !binary |
|
93
|
+
AA==
|
94
|
+
|
95
|
+
rubygems_version: 1.2.0
|
96
|
+
signing_key:
|
97
|
+
specification_version: 2
|
98
|
+
summary: A utility which walks a ColdFusion application's source and determines which includes, custom tags, etc, will not work with a case-sensitive filesystem
|
99
|
+
test_files: []
|
100
|
+
|