|
66 | 66 |
|
67 | 67 | it 'adds split java_opts to context' do
|
68 | 68 | component.release
|
69 |
| - |
70 | 69 | expect(java_opts).to include('-Xdebug')
|
71 | 70 | expect(java_opts).to include('-Xnoagent')
|
72 |
| - expect(java_opts).to include('-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y') |
| 71 | + expect(java_opts).to include('-Xrunjdwp:transport=dt_socket,server\=y,address\=8000,suspend\=y') |
73 | 72 | expect(java_opts).to include('-XX:OnOutOfMemoryError=kill\ -9\ \%p')
|
74 | 73 | end
|
75 | 74 | end
|
76 | 75 |
|
77 | 76 | context do
|
78 | 77 | let(:configuration) do
|
79 |
| - { 'java_opts' => '-Dtest=!£$%^&*(){}<>[];~`' } |
| 78 | + { 'java_opts' => '-Dtest=!£%^&*()<>[]{};~`' } |
80 | 79 | end
|
81 | 80 |
|
82 | 81 | it 'escapes special characters' do
|
83 | 82 | component.release
|
| 83 | + expect(java_opts).to include('-Dtest=\!\£\%\^\&\*\(\)\<\>\[\]\{\}\;\~\`') |
| 84 | + end |
| 85 | + end |
| 86 | + |
| 87 | + context do |
| 88 | + let(:configuration) do |
| 89 | + { 'java_opts' => '-Dtest=$DOLLAR\\\SLASH' } |
| 90 | + end |
| 91 | + |
| 92 | + it 'does not escape the shell variable character from configuration' do |
| 93 | + component.release |
| 94 | + expect(java_opts).to include('-Dtest=$DOLLAR\SLASH') |
| 95 | + end |
| 96 | + end |
84 | 97 |
|
85 |
| - expect(java_opts).to include('-Dtest=\\!\\£\\$\\%\\^\\&\\*\\(\\)\\{\\}\\<\\>\\[\\]\\;\\~\\`') |
| 98 | + context do |
| 99 | + let(:configuration) { { 'from_environment' => true } } |
| 100 | + let(:environment) { { 'JAVA_OPTS' => '-Dtest=$dollar\\\slash' } } |
| 101 | + |
| 102 | + it 'does not escape the shell variable character from environment' do |
| 103 | + component.release |
| 104 | + expect(java_opts).to include('-Dtest=$dollar\slash') |
86 | 105 | end
|
87 | 106 | end
|
88 | 107 |
|
89 | 108 | context do
|
90 | 109 | let(:configuration) do
|
91 |
| - { 'java_opts' => '-javaagent:agent.jar=port="\$PORT",host=localhost' } |
| 110 | + { 'java_opts' => '-Dtest=something.\\\$dollar.\\\\\\\slash' } |
92 | 111 | end
|
93 | 112 |
|
94 |
| - it 'allows escaped characters' do |
| 113 | + it 'can escape non-escaped characters ' do |
95 | 114 | component.release
|
| 115 | + expect(java_opts).to include('-Dtest=something.\\$dollar.\\\slash') |
| 116 | + end |
| 117 | + end |
96 | 118 |
|
97 |
| - expect(java_opts).to include('-javaagent:agent.jar=port=$PORT,host=localhost') |
| 119 | + context do |
| 120 | + let(:configuration) do |
| 121 | + { 'java_opts' => '-javaagent:agent.jar=port=$PORT,host=localhost' } |
| 122 | + end |
| 123 | + |
| 124 | + it 'escapes equal signs after the first one' do |
| 125 | + component.release |
| 126 | + expect(java_opts).to include('-javaagent:agent.jar=port\\=$PORT,host\\=localhost') |
98 | 127 | end
|
99 | 128 | end
|
100 | 129 |
|
|
0 commit comments