jdzak-cf_case_check 0.1.1

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.
@@ -0,0 +1,77 @@
1
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
+
3
+ describe CaseCheck::Cfc do
4
+ before(:each) do
5
+ CaseCheck::Cfc.directories = %w(/tmp/cfc_specs/components)
6
+ @source = create_test_source('/tmp/cfc_specs/theapp/quux.cfm', <<-CFM)
7
+ <cfparam name="url.summaryType">
8
+ <cfparam name="url.patient_id">
9
+ <cfparam name="url.summaryId" default="0">
10
+
11
+ <cfscript>
12
+ utilsObj = CreateObject("component","bspore.Utils").init(datasource=application.personnel_db,username=session.netid,userIP=cgi.remote_addr);
13
+ summaryObj = createObject("component","bspore.Summary").init(datasource=application.db,username=session.netid,userIP=cgi.remote_addr);
14
+ </cfscript>
15
+ CFM
16
+ end
17
+
18
+ after(:each) do
19
+ FileUtils.rm_r '/tmp/cfc_specs'
20
+ end
21
+
22
+ def actual_search
23
+ CaseCheck::Cfc.search(@source)
24
+ end
25
+
26
+ it "has a human-readable name" do
27
+ actual_search.first.type_name.should == 'cfc'
28
+ end
29
+
30
+ it "finds multiple invocations" do
31
+ actual_search.should have(2).references
32
+ end
33
+
34
+ it "finds lower case createObject style" do
35
+ actual_search.last.expected_path.should == "bspore/Summary.cfc"
36
+ end
37
+
38
+ it "finds upper case CreateObject style" do
39
+ actual_search.first.expected_path.should == "bspore/Utils.cfc"
40
+ end
41
+
42
+ it "resolves against an exact match" do
43
+ expected_file = CaseCheck::Cfc.directories.last + "/bspore/Utils.cfc"
44
+ touch expected_file
45
+ actual_search.first.resolved_to.should == expected_file
46
+ actual_search.first.resolution.should == :exact
47
+ end
48
+
49
+ it "resolves against an all-lowercase match as exact" do
50
+ expected_file = CaseCheck::Cfc.directories.last + "/bspore/utils.cfc"
51
+ touch expected_file
52
+ actual_search.first.resolved_to.should == expected_file
53
+ actual_search.first.resolution.should == :exact
54
+ end
55
+
56
+ it "resolves against an differently cased version as inexact" do
57
+ expected_file = CaseCheck::Cfc.directories.last + "/BSpore/Utils.cfc"
58
+ touch expected_file
59
+ actual_search.first.resolved_to.should == expected_file
60
+ actual_search.first.resolution.should == :case_insensitive
61
+ end
62
+
63
+ it "resolves against a match in the same directory as the file" do
64
+ expected_file = File.join(File.dirname(@source.filename), 'bspore/Utils.cfc')
65
+ touch expected_file
66
+ actual_search.first.resolved_to.should == expected_file
67
+ actual_search.first.resolution.should == :exact
68
+ end
69
+
70
+ it "performs substitutions before attempting to resolve" do
71
+ @source.content = <<-CFM
72
+ CreateObject("component", application.pathToComponents&"Personnel")
73
+ CFM
74
+ CaseCheck::Reference.substitutions << [/application.pathToComponents&/i, "pipes."]
75
+ actual_search.first.expected_path.should == "pipes/Personnel.cfc"
76
+ end
77
+ end
@@ -0,0 +1,74 @@
1
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
+
3
+ describe CaseCheck::Cfinclude do
4
+ before(:each) do
5
+ @source = create_test_source("/tmp/cfinc_specs/theapp/quux.cfm", <<-CFM)
6
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
7
+ "http://www.w3.org/TR/REC-html40/loose.dtd">
8
+ <HTML>
9
+ <HEAD>
10
+ <TITLE>Pick Permissions Report Options</TITLE>
11
+ <META NAME="generator" CONTENT="BBEdit 5.1.1">
12
+
13
+ <CFPARAM NAME="Session.Output_Type" DEFAULT="Browser">
14
+
15
+ <cfinclude template="../header_plain.html">
16
+ <h1>Pick Permissions Report Options</h1>
17
+
18
+ CFM
19
+ end
20
+
21
+ after(:each) do
22
+ FileUtils.rm_r '/tmp/cfinc_specs'
23
+ end
24
+
25
+ def actual_search
26
+ CaseCheck::Cfinclude.search(@source)
27
+ end
28
+
29
+ it "has a human-readable name" do
30
+ actual_search.first.type_name.should == 'cfinclude'
31
+ end
32
+
33
+ it "uses the template path as the path" do
34
+ actual_search.first.expected_path.should == "../header_plain.html"
35
+ end
36
+
37
+ it "resolves against file directory" do
38
+ expected_file = "/tmp/cfinc_specs/header_plain.html"
39
+ touch expected_file
40
+ actual_search.first.resolved_to.should == expected_file
41
+ actual_search.first.resolution.should == :exact
42
+ end
43
+
44
+ it "resolves against file directory case-insensitively" do
45
+ expected_file = "/tmp/cfinc_specs/headER_plain.html"
46
+ touch expected_file
47
+ actual_search.first.resolved_to.should == expected_file
48
+ actual_search.first.resolution.should == :case_insensitive
49
+ end
50
+
51
+ it "finds multiple cfincludes" do
52
+ @source.content = <<-CFM
53
+ <cfinclude template="etc"/>
54
+ And then something else happened.
55
+ <cfinclude template="etal">
56
+ CFM
57
+ actual_search.should have(2).references
58
+ end
59
+
60
+ it "finds the cfinclude tag without regard to case" do
61
+ @source.content = <<-CFM
62
+ <CFInclude template="whatever">
63
+ CFM
64
+ actual_search.should have(1).reference
65
+ end
66
+
67
+ it "performs substitutions before resolving" do
68
+ @source.content = <<-CFM
69
+ <cfinclude template="#application.myroot#whatever.cfm">
70
+ CFM
71
+ CaseCheck::Reference.substitutions << [/#application.myroot#/, 'etc/']
72
+ actual_search.first.expected_path.should == 'etc/whatever.cfm'
73
+ end
74
+ end
@@ -0,0 +1,156 @@
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
+
80
+ it "performs substitutions before resolving" do
81
+ @source.content = <<-CFM
82
+ <cfmodule name="#application.myroot#whatever">
83
+ CFM
84
+ CaseCheck::Reference.substitutions << [/#application.myroot#/, 'etc.']
85
+ actual_search.first.expected_path.should == 'etc/whatever.cfm'
86
+ end
87
+ end
88
+
89
+ describe CaseCheck::Cfmodule::Template do
90
+ before(:each) do
91
+ @source = create_test_source("/tmp/cfmod_specs/theapp/quux.cfm", <<-CFM)
92
+ <CFOUTPUT>
93
+ <CFIF StoredQueryID GT 0>
94
+ storedqueryid : #StoredQueryID#
95
+ <CFModule Template="GetTheStoredStatement.cfm" datasource="#tablespace#" QueryName="#StoredQueryName#"
96
+ category="#querycategory#" sq_id=#StoredQueryID#>
97
+ <CFSET sqlstatement=TheStoredStatement>
98
+ </CFIF>
99
+ </CFOUTPUT>
100
+ CFM
101
+ end
102
+
103
+ after(:each) do
104
+ FileUtils.rm_r '/tmp/cfmod_specs'
105
+ end
106
+
107
+ def actual_search
108
+ CaseCheck::Cfmodule.search(@source)
109
+ end
110
+
111
+ it "has a human-readable name" do
112
+ actual_search.first.type_name.should == 'cfmodule with template'
113
+ end
114
+
115
+ it "uses the template path as the path" do
116
+ actual_search.first.expected_path.should == "GetTheStoredStatement.cfm"
117
+ end
118
+
119
+ it "resolves against file directory" do
120
+ expected_file = "/tmp/cfmod_specs/theapp/GetTheStoredStatement.cfm"
121
+ touch expected_file
122
+ actual_search.first.resolved_to.should == expected_file
123
+ actual_search.first.resolution.should == :exact
124
+ end
125
+
126
+ it "resolves against file directory case-insensitively" do
127
+ expected_file = "/tmp/cfmod_specs/theapp/GetTheSTOREDStatement.cfm"
128
+ touch expected_file
129
+ actual_search.first.resolved_to.should == expected_file
130
+ actual_search.first.resolution.should == :case_insensitive
131
+ end
132
+
133
+ it "finds multiple cfmodule references" do
134
+ @source.content = <<-CFM
135
+ <cfmodule template="etc"/>
136
+ <cfmodule template="etal">
137
+ CFM
138
+ actual_search.should have(2).references
139
+ end
140
+
141
+ it "finds the cfmodule tag without regard to case" do
142
+ @source.content = <<-CFM
143
+ <cfMODule template="whatever">
144
+ CFM
145
+ actual_search.should have(1).reference
146
+ end
147
+
148
+
149
+ it "performs substitutions before resolving" do
150
+ @source.content = <<-CFM
151
+ <cfmodule template="#application.somePath#whatever.cfm">
152
+ CFM
153
+ CaseCheck::Reference.substitutions << [/#application.somePath#/, 'etc/']
154
+ actual_search.first.expected_path.should == 'etc/whatever.cfm'
155
+ end
156
+ 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
@@ -0,0 +1,38 @@
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
+ CaseCheck::Reference.substitutions.clear
13
+ end
14
+
15
+ # == Mock Framework
16
+ #
17
+ # RSpec uses it's own mocking framework by default. If you prefer to
18
+ # use mocha, flexmock or RR, uncomment the appropriate line:
19
+ #
20
+ # config.mock_with :mocha
21
+ # config.mock_with :flexmock
22
+ # config.mock_with :rr
23
+ end
24
+
25
+ def create_test_source(filename, content)
26
+ FileUtils.mkdir_p File.dirname(filename)
27
+
28
+ File.open(filename, 'w') do |f|
29
+ f.write content
30
+ end
31
+
32
+ CaseCheck::ColdfusionSource.create(filename)
33
+ end
34
+
35
+ def touch(filename)
36
+ FileUtils.mkdir_p File.dirname(filename)
37
+ FileUtils.touch filename
38
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jdzak-cf_case_check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Rhett Sutphin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-15 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:
93
+ rubygems_version: 1.2.0
94
+ signing_key:
95
+ specification_version: 2
96
+ 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
97
+ test_files: []
98
+