redmine-installer 2.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,204 +0,0 @@
1
- module InstallerHelper
2
-
3
- def db_username
4
- ENV['SPEC_DB_USERNAME'].to_s
5
- end
6
-
7
- def db_password
8
- ENV['SPEC_DB_PASSWORD'].to_s
9
- end
10
-
11
- def expected_output(text)
12
- expect(@process).to have_output(text)
13
- end
14
-
15
- def expected_output_in(text, max_wait)
16
- expect(@process).to have_output_in(text, max_wait)
17
- end
18
-
19
- def write(text)
20
- @process.write(text + "\n")
21
- end
22
-
23
- # Be carefull - this could have later unpredictable consequences on stdin
24
- def select_choice
25
- # @process.write(' ')
26
- @process.write("\r")
27
- # @process.write("\r\n")
28
- end
29
-
30
- def go_up
31
- @process.write("\e[A")
32
- end
33
-
34
- def go_down
35
- # write(TTY::Reader::Keys.keys[:down])
36
- # write("\e[B")
37
- @process.write("\e[B")
38
- end
39
-
40
- def email_username
41
- 'username'
42
- end
43
-
44
- def email_password
45
- 'password'
46
- end
47
-
48
- def email_address
49
- 'address'
50
- end
51
-
52
- def email_port
53
- '123'
54
- end
55
-
56
- def email_domain
57
- 'domain'
58
- end
59
-
60
- def email_authentication
61
- 'plain'
62
- end
63
-
64
- def email_openssl_verify_mode
65
- 'none'
66
- end
67
-
68
- def email_enable_tls
69
- false
70
- end
71
-
72
- def email_enable_starttls
73
- true
74
- end
75
-
76
- def expected_successful_configuration(email: false)
77
- expected_output('Creating database configuration')
78
- expected_output('What database do you want use?')
79
- expected_output('‣ MySQL')
80
-
81
- go_down
82
- expected_output('‣ PostgreSQL')
83
- select_choice
84
-
85
- expected_output('Database:')
86
- write('test')
87
-
88
- expected_output('Host: (localhost)')
89
- write('')
90
-
91
- expected_output('Username:')
92
- write(db_username)
93
-
94
- expected_output('Password:')
95
- write(db_password)
96
-
97
- expected_output('Encoding: (utf8)')
98
- write('')
99
-
100
- expected_output('Port: (5432)')
101
- write('')
102
-
103
- expected_output('Creating email configuration')
104
- expected_output('Which service to use for email sending?')
105
-
106
- if email
107
- go_up
108
- go_up
109
- go_up
110
- expected_output('‣ Custom configuration (SMTP)')
111
- select_choice
112
-
113
- expected_output('Username:')
114
- write(email_username)
115
-
116
- expected_output('Password:')
117
- write(email_password)
118
-
119
- expected_output('Address:')
120
- write(email_address)
121
-
122
- expected_output('Port:')
123
- write(email_port)
124
-
125
- expected_output('Domain:')
126
- write(email_domain)
127
-
128
- expected_output('Authentication:')
129
- write(email_authentication)
130
-
131
- expected_output('Openssl verify mode:')
132
- write(email_openssl_verify_mode)
133
-
134
- expected_output('Enable tls?: (y/N)')
135
- write(email_enable_tls ? 'y' : 'n')
136
-
137
- expected_output('Enable starttls?: (Y/n)')
138
- write(email_enable_starttls ? 'y' : 'n')
139
- else
140
- expected_output('‣ Nothing')
141
- select_choice
142
- end
143
- end
144
-
145
- def expected_successful_installation_or_upgrade(db_creating: false, after_create: nil)
146
- expected_output_in('--> Bundle install', 50)
147
- expected_output_in('--> Database creating', 50) if db_creating
148
- after_create && after_create.call
149
- expected_output_in('--> Database migrating', 50)
150
- expected_output_in('--> Plugins migration', 50)
151
- expected_output_in('--> Generating secret token', 50)
152
-
153
- expected_output('Cleaning root ... OK')
154
- expected_output('Moving redmine to target directory ... OK')
155
- expected_output('Cleanning up ... OK')
156
- expected_output('Moving installer log ... OK')
157
- end
158
-
159
- def expected_successful_installation(**options)
160
- expected_output('Redmine installing')
161
- expected_successful_installation_or_upgrade(db_creating: true, **options)
162
- expected_output('Redmine was installed')
163
- end
164
-
165
- def expected_successful_upgrade
166
- expected_output('Redmine upgrading')
167
- expected_successful_installation_or_upgrade
168
- expected_output('Redmine was upgraded')
169
-
170
- expected_output('Do you want save steps for further use?')
171
- write('n')
172
- end
173
-
174
- def expected_redmine_version(version)
175
- Dir.chdir(@redmine_root) do
176
- out = `rails runner "puts Redmine::VERSION.to_s"`
177
- expect($?.success?).to be_truthy
178
- expect(out).to include(version)
179
- end
180
- end
181
-
182
- def expected_email_configuration
183
- Dir.chdir(@redmine_root) do
184
- configuration = YAML.load_file('config/configuration.yml')['default']['email_delivery']
185
- smtp_settings = configuration['smtp_settings']
186
-
187
- expect(configuration['delivery_method']).to eq(:smtp)
188
- expect(smtp_settings['address']).to eq(email_address)
189
- expect(smtp_settings['port']).to eq(email_port.to_i)
190
- expect(smtp_settings['authentication']).to eq(email_authentication.to_sym)
191
- expect(smtp_settings['domain']).to eq(email_domain)
192
- expect(smtp_settings['user_name']).to eq(email_username)
193
- expect(smtp_settings['password']).to eq(email_password)
194
- expect(smtp_settings['tls']).to eq(email_enable_tls)
195
- expect(smtp_settings['enable_starttls_auto']).to eq(email_enable_starttls)
196
- expect(smtp_settings['openssl_verify_mode']).to eq(email_openssl_verify_mode)
197
- end
198
- end
199
-
200
- def wait_for_stdin_buffer
201
- sleep 0.5
202
- end
203
-
204
- end
@@ -1,94 +0,0 @@
1
- require 'childprocess'
2
-
3
- class InstallerProcess
4
-
5
- attr_reader :stdout, :last_get_return
6
-
7
- def initialize(command, *args)
8
- tempfile_out = File.open('redmine-installer-out', 'w')
9
- tempfile_err = File.open('redmine-installer-err', 'w')
10
-
11
- tempfile_out.sync = true
12
- tempfile_err.sync = true
13
-
14
- args = args.flatten.compact
15
-
16
- if ['install', 'upgrade'].include?(command)
17
- args << '--bundle-options' << '--without rmagick'
18
- end
19
-
20
- redmine_bin_file = File.expand_path('../bin/redmine', __dir__)
21
-
22
- @process = ChildProcess.build(redmine_bin_file, command, *args)
23
- # @process = ChildProcess.build('bin/redmine', command, *args)
24
- # @process = ChildProcess.build('redmine', command, *args)
25
- @process.io.stdout = tempfile_out
26
- @process.io.stderr = tempfile_err
27
- @process.environment['REDMINE_INSTALLER_SPEC'] = '1'
28
- @process.environment['REDMINE_INSTALLER_LOGFILE'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'log.log'))
29
- @process.duplex = true
30
- @process.detach = true
31
-
32
- # Because of file description is shared with redmine installer
33
- # so changing posiiotn has effect fot both processes
34
- @stdout = File.open(tempfile_out.path)
35
-
36
- @last_get_return = ''
37
- @buffer = ''
38
- @seek = 0
39
- end
40
-
41
- def run
42
- Bundler.with_unbundled_env {
43
- start
44
- yield
45
- }
46
- ensure
47
- stop
48
- end
49
-
50
- def start
51
- @process.start
52
- end
53
-
54
- def stop
55
- @process.stop
56
- end
57
-
58
- def write(text)
59
- @process.io.stdin << text
60
-
61
- # @process.io.stdin.puts(text)
62
- # @process.io.stdin.flush
63
-
64
- # @process.io.stdin.syswrite(text + "\n")
65
- # @process.io.stdin.flush
66
-
67
- # @process.io.stdin.write_nonblock(text + "\n")
68
- end
69
-
70
- def get(text, **args)
71
- @last_get_return = _get(text, **args)
72
- end
73
-
74
- private
75
-
76
- # max_wait in s
77
- def _get(text, max_wait: 10)
78
- wait_to = Time.now + max_wait
79
- while Time.now < wait_to
80
- @buffer << @stdout.read
81
- index = @buffer.rindex(text)
82
-
83
- if index
84
- break
85
- # return @buffer.slice!(0, index+text.size)
86
- else
87
- sleep 0.5
88
- end
89
- end
90
-
91
- @buffer
92
- end
93
-
94
- end
@@ -1,81 +0,0 @@
1
- require 'spec_helper'
2
-
3
- DATABASE_DUMP = File.join(Dir.tmpdir, 'redmine_installer_database_backup.sql')
4
-
5
- RSpec.describe 'RedmineInstaller backup / restore', order: :defined do
6
-
7
- let(:project_count) { 5 }
8
-
9
- it 'create backup', :install_first, command: 'backup' do
10
- # First ensure `project_count` project
11
- Dir.chdir(@redmine_root) do
12
- out = `rails runner "
13
- Project.delete_all
14
-
15
- #{project_count}.times do |i|
16
- p = Project.new
17
- p.name = 'Test ' + i.to_s
18
- p.identifier = 'test_' + i.to_s
19
- p.save(validate: false)
20
- end
21
-
22
- puts Project.count
23
- "`
24
-
25
- expect($?.success?).to be_truthy
26
- expect(out.to_i).to eq(project_count)
27
- end
28
-
29
- # Backup database
30
- expected_output('Path to redmine root:')
31
- write(@redmine_root)
32
- expected_output('Data backup')
33
- go_down
34
- expected_output('‣ Only database')
35
- select_choice
36
- expected_output('Where to save backup:')
37
- write(@backup_dir)
38
- expected_output('Database backuping')
39
- expected_output('Database backed up')
40
-
41
- # Ensure 0 project (database is shared with all tests)
42
- Dir.chdir(@redmine_root) do
43
- out = `rails runner "
44
- Project.delete_all
45
- puts Project.count
46
- "`
47
-
48
- expect($?.success?).to be_truthy
49
- expect(out.to_i).to eq(0)
50
- end
51
-
52
- # Save backup (after test end - all backup will be deleted)
53
- dump = Dir.glob(File.join(@backup_dir, '*', '*')).last
54
- expect(dump).to end_with('test.sql')
55
-
56
- FileUtils.rm_f(DATABASE_DUMP)
57
- FileUtils.cp(dump, DATABASE_DUMP)
58
- end
59
-
60
- it 'restore', command: 'install', args: [package_v503, '--database-dump', DATABASE_DUMP] do
61
- expected_output('Path to redmine root:')
62
- write(@redmine_root)
63
-
64
- expected_successful_configuration
65
-
66
- expected_output('Database dump will be loaded.')
67
- expected_output('‣ Skip dump loading')
68
-
69
- go_down
70
- expected_output('‣ I am aware of this.')
71
- select_choice
72
-
73
- expected_output_in('Redmine was installed', 500)
74
-
75
- Dir.chdir(@redmine_root) do
76
- out = `rails runner "puts Project.count"`
77
- expect(out.to_i).to eq(project_count)
78
- end
79
- end
80
-
81
- end
@@ -1,164 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe RedmineInstaller::Install, command: 'install' do
4
-
5
- it 'unreadable file', args: [] do
6
- FileUtils.chmod(0000, @redmine_root)
7
-
8
- expected_output('Path to redmine root:')
9
- write(@redmine_root)
10
-
11
- expected_output('Application root contains unreadable files')
12
-
13
- FileUtils.chmod(0600, @redmine_root)
14
- end
15
-
16
- it 'unwritable directory', args: [] do
17
- directory = File.join(@redmine_root, 'directory')
18
- subdirectory = File.join(directory, 'subdirectory')
19
-
20
- FileUtils.mkdir_p(subdirectory)
21
- FileUtils.chmod(0444, directory)
22
-
23
- expected_output('Path to redmine root:')
24
- write(@redmine_root)
25
-
26
- expected_output('Application root contains unreadable files')
27
-
28
- FileUtils.chmod(0700, directory)
29
- end
30
-
31
- it 'non-existinig package', args: [] do
32
- this_file = File.expand_path(File.join(File.dirname(__FILE__)))
33
-
34
- expected_output('Path to redmine root:')
35
- write(@redmine_root)
36
-
37
- expected_output('Path to package:')
38
- write(this_file)
39
-
40
- expected_output("File #{this_file} must have format: .zip, .gz, .tgz")
41
- end
42
-
43
- it 'non-existinig zip package', args: [] do
44
- expected_output('Path to redmine root:')
45
- write(@redmine_root)
46
-
47
- expected_output('Path to package:')
48
- write('aaa.zip')
49
-
50
- expected_output("File doesn't exist")
51
- end
52
-
53
- it 'install without arguments', args: [] do
54
- expected_output('Path to redmine root:')
55
- write(@redmine_root)
56
-
57
- expected_output('Path to package:')
58
- write(package_v503)
59
-
60
- expected_output('Extracting redmine package')
61
-
62
- expected_successful_configuration(email: true)
63
- expected_successful_installation
64
-
65
- expected_redmine_version('5.0.3')
66
- expected_email_configuration
67
- end
68
-
69
- it 'download redmine', args: ['v5.0.3'] do
70
- expected_output('Path to redmine root:')
71
- write(@redmine_root)
72
-
73
- expected_output_in('Downloading https://www.redmine.org/releases/redmine-5.0.3.zip', 30)
74
- expected_output('Extracting redmine package')
75
-
76
- expected_successful_configuration
77
- expected_successful_installation
78
-
79
- expected_redmine_version('5.0.3')
80
- end
81
-
82
- it 'installing something else', args: [package_someting_else] do
83
- write(@redmine_root)
84
-
85
- expected_output('is not valid')
86
- end
87
-
88
- it 'bad database settings', args: [package_v503] do
89
- write(@redmine_root)
90
-
91
- expected_output('Creating database configuration')
92
- go_down
93
- expected_output('‣ PostgreSQL')
94
- write('')
95
-
96
- write('test')
97
- write('')
98
- write('testtesttest')
99
- sleep 0.5 # wait for buffer
100
- write(db_password)
101
- write('')
102
- write('')
103
-
104
- expected_output('Creating email configuration')
105
- write('')
106
-
107
- expected_output('Redmine installing')
108
- expected_output_in('--> Database migrating', 60)
109
- expected_output('Migration end with error')
110
- expected_output('‣ Try again')
111
-
112
- go_down
113
- go_down
114
- expected_output('‣ Change database configuration')
115
- write('')
116
-
117
- go_down
118
- expected_output('‣ PostgreSQL')
119
- write('')
120
-
121
- write('test')
122
- write('')
123
- write(db_username)
124
- sleep 0.5 # wait for buffer
125
- write(db_password)
126
- write('')
127
- write('')
128
-
129
- expected_output('--> Database migrating')
130
- expected_output_in('Redmine was installed', 60)
131
-
132
- expected_redmine_version('5.0.3')
133
- end
134
-
135
- it 'high installer version', args: [package_high_installer_version] do
136
- write(@redmine_root)
137
- expected_output('You are using an old version of installer')
138
- end
139
-
140
- it 'download redmine', args: [package_default_db] do
141
- expected_output('Path to redmine root:')
142
- write(@redmine_root)
143
-
144
- expected_successful_configuration
145
- expected_successful_installation(
146
- after_create: proc {
147
- expected_output('Would you like to load default data')
148
-
149
- write('y')
150
- expected_output('Database cleaning')
151
- expected_output('Database restoring')
152
- }
153
- )
154
-
155
- expected_redmine_version('3.4.5')
156
-
157
- Dir.chdir(@redmine_root) do
158
- out = `rails runner "puts Issue.count"`.strip
159
- expect($?.success?).to be_truthy
160
- expect(out).to eq('3')
161
- end
162
- end
163
-
164
- end