boxen23 3.1.3a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.md +50 -0
- data/boxen.gemspec +29 -0
- data/lib/boxen/check.rb +72 -0
- data/lib/boxen/checkout.rb +25 -0
- data/lib/boxen/cli.rb +61 -0
- data/lib/boxen/config.rb +345 -0
- data/lib/boxen/error.rb +4 -0
- data/lib/boxen/flags.rb +291 -0
- data/lib/boxen/hook.rb +47 -0
- data/lib/boxen/hook/github_issue.rb +120 -0
- data/lib/boxen/hook/web.rb +56 -0
- data/lib/boxen/keychain.rb +61 -0
- data/lib/boxen/postflight.rb +13 -0
- data/lib/boxen/postflight/active.rb +16 -0
- data/lib/boxen/postflight/env.rb +29 -0
- data/lib/boxen/preflight.rb +13 -0
- data/lib/boxen/preflight/creds.rb +149 -0
- data/lib/boxen/preflight/directories.rb +32 -0
- data/lib/boxen/preflight/etc_my_cnf.rb +12 -0
- data/lib/boxen/preflight/identity.rb +16 -0
- data/lib/boxen/preflight/os.rb +33 -0
- data/lib/boxen/preflight/rbenv.rb +12 -0
- data/lib/boxen/preflight/rvm.rb +12 -0
- data/lib/boxen/project.rb +20 -0
- data/lib/boxen/puppeteer.rb +122 -0
- data/lib/boxen/runner.rb +149 -0
- data/lib/boxen/service.rb +58 -0
- data/lib/boxen/util.rb +19 -0
- data/lib/facter/boxen.rb +34 -0
- data/script/Boxen +0 -0
- data/script/bootstrap +7 -0
- data/script/build-keychain-helper +6 -0
- data/script/release +38 -0
- data/script/tests +10 -0
- data/src/keychain-helper.c +85 -0
- data/test/boxen/test.rb +7 -0
- data/test/boxen_check_test.rb +55 -0
- data/test/boxen_checkout_test.rb +42 -0
- data/test/boxen_cli_test.rb +39 -0
- data/test/boxen_config_test.rb +400 -0
- data/test/boxen_directories_test.rb +40 -0
- data/test/boxen_flags_test.rb +223 -0
- data/test/boxen_hook_github_issue_test.rb +294 -0
- data/test/boxen_hook_web_test.rb +58 -0
- data/test/boxen_keychain_test.rb +21 -0
- data/test/boxen_postflight_active_test.rb +29 -0
- data/test/boxen_postflight_env_test.rb +6 -0
- data/test/boxen_preflight_creds_test.rb +177 -0
- data/test/boxen_preflight_etc_my_cnf_test.rb +10 -0
- data/test/boxen_preflight_rvm_test.rb +10 -0
- data/test/boxen_project_test.rb +14 -0
- data/test/boxen_puppeteer_test.rb +101 -0
- data/test/boxen_runner_test.rb +171 -0
- data/test/boxen_service_test.rb +39 -0
- data/test/boxen_util_test.rb +21 -0
- data/test/fixtures/repo/modules/projects/manifests/first-project.pp +0 -0
- data/test/fixtures/repo/modules/projects/manifests/second-project.pp +0 -0
- metadata +257 -0
data/script/release
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Tag and push a release.
|
3
|
+
|
4
|
+
set -e
|
5
|
+
|
6
|
+
# Make sure we're in the project root.
|
7
|
+
|
8
|
+
cd $(dirname "$0")/..
|
9
|
+
|
10
|
+
# Build a new gem archive.
|
11
|
+
|
12
|
+
rm -rf boxen-*.gem
|
13
|
+
gem build -q boxen.gemspec
|
14
|
+
|
15
|
+
# Make sure we're on the master branch.
|
16
|
+
|
17
|
+
(git branch | grep -q '* master') || {
|
18
|
+
echo "Only release from the master branch."
|
19
|
+
exit 1
|
20
|
+
}
|
21
|
+
|
22
|
+
# Figure out what version we're releasing.
|
23
|
+
|
24
|
+
tag=v`ls boxen-*.gem | sed 's/^boxen-\(.*\)\.gem$/\1/'`
|
25
|
+
|
26
|
+
# Make sure we haven't released this version before.
|
27
|
+
|
28
|
+
git fetch -t origin
|
29
|
+
|
30
|
+
(git tag -l | grep -q "$tag") && {
|
31
|
+
echo "Whoops, there's already a '${tag}' tag."
|
32
|
+
exit 1
|
33
|
+
}
|
34
|
+
|
35
|
+
# Tag it and bag it.
|
36
|
+
|
37
|
+
gem push boxen-*.gem && git tag "$tag" &&
|
38
|
+
git push origin master && git push origin "$tag"
|
data/script/tests
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdlib.h>
|
3
|
+
#include <Security/Security.h>
|
4
|
+
#include <CoreFoundation/CFString.h>
|
5
|
+
|
6
|
+
#define REPORT_KEYCHAIN_ERROR(err_val) do { \
|
7
|
+
fprintf(stderr, "Boxen Keychain Helper: Encountered error code: %d\n", err_val); \
|
8
|
+
fprintf(stderr, "Error: %s\n", CFStringGetCStringPtr(SecCopyErrorMessageString(err_val, NULL), kCFStringEncodingMacRoman)); \
|
9
|
+
} while(0)
|
10
|
+
|
11
|
+
int key_exists_p(
|
12
|
+
const char *service,
|
13
|
+
const char *login,
|
14
|
+
SecKeychainItemRef *item
|
15
|
+
) {
|
16
|
+
void *buf;
|
17
|
+
UInt32 len;
|
18
|
+
|
19
|
+
OSStatus ret = SecKeychainFindGenericPassword(
|
20
|
+
NULL, strlen(service), service, strlen(login), login, &len, &buf, item
|
21
|
+
);
|
22
|
+
|
23
|
+
if (ret == errSecSuccess) {
|
24
|
+
return 0;
|
25
|
+
} else {
|
26
|
+
if (ret != errSecItemNotFound) {
|
27
|
+
// Item not found is not an error in predicate method context.
|
28
|
+
REPORT_KEYCHAIN_ERROR(ret);
|
29
|
+
}
|
30
|
+
return ret;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
int main(int argc, char **argv) {
|
35
|
+
if ((argc < 3) || (argc > 4)) {
|
36
|
+
printf("Usage: %s <service> <account> [<password>]\n", argv[0]);
|
37
|
+
return 1;
|
38
|
+
}
|
39
|
+
|
40
|
+
const char *service = argv[1];
|
41
|
+
const char *login = argv[2];
|
42
|
+
const char *password = argc == 4 ? argv[3] : NULL;
|
43
|
+
|
44
|
+
void *buf;
|
45
|
+
UInt32 len;
|
46
|
+
SecKeychainItemRef item;
|
47
|
+
|
48
|
+
if (password != NULL && strlen(password) != 0) {
|
49
|
+
if (key_exists_p(service, login, &item) == 0) {
|
50
|
+
SecKeychainItemDelete(item);
|
51
|
+
}
|
52
|
+
|
53
|
+
OSStatus create_key = SecKeychainAddGenericPassword(
|
54
|
+
NULL, strlen(service), service, strlen(login), login, strlen(password),
|
55
|
+
password, &item
|
56
|
+
);
|
57
|
+
|
58
|
+
if (create_key != 0) {
|
59
|
+
REPORT_KEYCHAIN_ERROR(create_key);
|
60
|
+
return 1;
|
61
|
+
}
|
62
|
+
} else if (password != NULL && strlen(password) == 0) {
|
63
|
+
if (key_exists_p(service, login, &item) == 0) {
|
64
|
+
OSStatus ret = SecKeychainItemDelete(item);
|
65
|
+
if (ret != errSecSuccess) {
|
66
|
+
REPORT_KEYCHAIN_ERROR(ret);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
} else {
|
70
|
+
OSStatus find_key = SecKeychainFindGenericPassword(
|
71
|
+
NULL, strlen(service), service, strlen(login), login, &len, &buf, &item);
|
72
|
+
|
73
|
+
if (find_key == errSecItemNotFound) {
|
74
|
+
return find_key;
|
75
|
+
}
|
76
|
+
if (find_key != 0) {
|
77
|
+
REPORT_KEYCHAIN_ERROR(find_key);
|
78
|
+
return 1;
|
79
|
+
}
|
80
|
+
|
81
|
+
fwrite(buf, 1, len, stdout);
|
82
|
+
}
|
83
|
+
|
84
|
+
return 0;
|
85
|
+
}
|
data/test/boxen/test.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "boxen/test"
|
2
|
+
require "boxen/check"
|
3
|
+
|
4
|
+
class BoxenCheckTest < Boxen::Test
|
5
|
+
def test_initialize
|
6
|
+
check = Boxen::Check.new :config
|
7
|
+
assert_equal :config, check.config
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_ok?
|
11
|
+
ex = assert_raises RuntimeError do
|
12
|
+
Boxen::Check.new(:config).ok?
|
13
|
+
end
|
14
|
+
|
15
|
+
assert_match "must implement", ex.message
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_run
|
19
|
+
ex = assert_raises RuntimeError do
|
20
|
+
Boxen::Check.new(:config).run
|
21
|
+
end
|
22
|
+
|
23
|
+
assert_match "must implement", ex.message
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_self_checks
|
27
|
+
subclass = Class.new Boxen::Check
|
28
|
+
Boxen::Check.const_set :TestCheck, subclass
|
29
|
+
|
30
|
+
assert Boxen::Check.checks(:config).any? { |c| subclass === c },
|
31
|
+
"an instance of TestCheck exists in checks"
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_self_checks_subclasses
|
35
|
+
klass = Struct.new :config
|
36
|
+
Boxen::Check.const_set :TestBadCheck, klass
|
37
|
+
|
38
|
+
refute Boxen::Check.checks(:config).any? { |c| klass === c },
|
39
|
+
"checks are subclasses of Boxen::Check"
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_self_run
|
43
|
+
willrun = mock do
|
44
|
+
expects(:ok?).returns false
|
45
|
+
expects(:run)
|
46
|
+
end
|
47
|
+
|
48
|
+
wontrun = mock do
|
49
|
+
expects(:ok?).returns true
|
50
|
+
end
|
51
|
+
|
52
|
+
Boxen::Check.expects(:checks).with(:config).returns [willrun, wontrun]
|
53
|
+
Boxen::Check.run :config
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "boxen/test"
|
2
|
+
require "boxen/checkout"
|
3
|
+
|
4
|
+
class BoxenCheckoutTest < Boxen::Test
|
5
|
+
def setup
|
6
|
+
@config = Boxen::Config.new { |c| c.repodir = 'test/fixtures/repo' }
|
7
|
+
@checkout = Boxen::Checkout.new @config
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_initialize
|
11
|
+
checkout = Boxen::Checkout.new :config
|
12
|
+
assert_equal :config, checkout.config
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_sha
|
16
|
+
sha = 'deadbeef'
|
17
|
+
@checkout.expects(:"`").with("git rev-parse HEAD").returns("#{sha}\n")
|
18
|
+
assert_equal sha, @checkout.sha
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_master?
|
22
|
+
@checkout.stubs(:"`").with("git symbolic-ref HEAD").returns("refs/heads/topic\n")
|
23
|
+
assert !@checkout.master?
|
24
|
+
|
25
|
+
@checkout.stubs(:"`").with("git symbolic-ref HEAD").returns("refs/heads/master\n")
|
26
|
+
assert @checkout.master?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_changes
|
30
|
+
changes = ' maybe a bunch of stuff happened '
|
31
|
+
@checkout.expects(:"`").with("git status --porcelain").returns(changes)
|
32
|
+
assert_equal changes.strip, @checkout.changes
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_dirty?
|
36
|
+
@checkout.stubs(:changes).returns('stuff happened')
|
37
|
+
assert @checkout.dirty?
|
38
|
+
|
39
|
+
@checkout.stubs(:changes).returns('')
|
40
|
+
assert !@checkout.dirty?
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "boxen/test"
|
2
|
+
require "boxen/cli"
|
3
|
+
|
4
|
+
class BoxenCLITest < Boxen::Test
|
5
|
+
def setup
|
6
|
+
@config = Boxen::Config.new
|
7
|
+
@flags = Boxen::Flags.new
|
8
|
+
@cli = Boxen::CLI.new(@config, @flags)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_initialize
|
12
|
+
config = Boxen::Config.new
|
13
|
+
flags = Boxen::Flags.new
|
14
|
+
|
15
|
+
cli = Boxen::CLI.new config, flags
|
16
|
+
|
17
|
+
assert_equal config, cli.config
|
18
|
+
assert_equal flags, cli.flags
|
19
|
+
|
20
|
+
assert_equal config, cli.runner.config
|
21
|
+
assert_equal flags, cli.runner.flags
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_run
|
25
|
+
@cli.runner.expects(:run)
|
26
|
+
@cli.run
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_help
|
30
|
+
$stdout.stubs(:write)
|
31
|
+
|
32
|
+
flags = Boxen::Flags.new('--help')
|
33
|
+
cli = Boxen::CLI.new(@config, flags)
|
34
|
+
cli.runner.expects(:run).never
|
35
|
+
assert_raises SystemExit do
|
36
|
+
cli.run
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,400 @@
|
|
1
|
+
require "boxen/test"
|
2
|
+
require "boxen/config"
|
3
|
+
|
4
|
+
class BoxenConfigTest < Boxen::Test
|
5
|
+
def setup
|
6
|
+
@config = Boxen::Config.new
|
7
|
+
@config.repodir = "test/fixtures/repo"
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_debug?
|
11
|
+
refute @config.debug?
|
12
|
+
|
13
|
+
@config.debug = true
|
14
|
+
assert @config.debug?
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_email
|
18
|
+
assert_nil @config.email
|
19
|
+
|
20
|
+
@config.email = "foo"
|
21
|
+
assert_equal "foo", @config.email
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_fde?
|
25
|
+
assert @config.fde?
|
26
|
+
|
27
|
+
@config.fde = false
|
28
|
+
refute @config.fde?
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_fde_env_var
|
32
|
+
val = ENV["BOXEN_NO_FDE"]
|
33
|
+
|
34
|
+
ENV["BOXEN_NO_FDE"] = "1"
|
35
|
+
refute @config.fde?
|
36
|
+
|
37
|
+
ENV["BOXEN_NO_FDE"] = val
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_homedir
|
41
|
+
val = ENV["BOXEN_HOME"]
|
42
|
+
ENV["BOXEN_HOME"] = nil
|
43
|
+
|
44
|
+
assert_equal "/opt/boxen", @config.homedir
|
45
|
+
|
46
|
+
@config.homedir = "foo"
|
47
|
+
assert_equal "foo", @config.homedir
|
48
|
+
|
49
|
+
ENV["BOXEN_HOME"] = val
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_homedir_env_var_boxen_home
|
53
|
+
val = ENV["BOXEN_HOME"]
|
54
|
+
|
55
|
+
ENV["BOXEN_HOME"] = "foo"
|
56
|
+
assert_equal "foo", @config.homedir
|
57
|
+
|
58
|
+
ENV["BOXEN_HOME"] = val
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_initialize
|
62
|
+
config = Boxen::Config.new do |c|
|
63
|
+
c.homedir = "foo"
|
64
|
+
end
|
65
|
+
|
66
|
+
assert_equal "foo", config.homedir
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_logfile
|
70
|
+
assert_equal "#{@config.repodir}/log/boxen.log", @config.logfile
|
71
|
+
|
72
|
+
@config.logfile = "foo"
|
73
|
+
assert_equal "foo", @config.logfile
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_logfile_env_var
|
77
|
+
val = ENV["BOXEN_LOG_FILE"]
|
78
|
+
|
79
|
+
ENV["BOXEN_LOG_FILE"] = "foo"
|
80
|
+
assert_equal "foo", @config.logfile
|
81
|
+
|
82
|
+
ENV["BOXEN_LOG_FILE"] = val
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_login
|
86
|
+
assert_nil @config.login
|
87
|
+
|
88
|
+
@config.login = "foo"
|
89
|
+
assert_equal "foo", @config.login
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_name
|
93
|
+
assert_nil @config.name
|
94
|
+
|
95
|
+
@config.name = "foo"
|
96
|
+
assert_equal "foo", @config.name
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_pretend?
|
100
|
+
refute @config.pretend?
|
101
|
+
|
102
|
+
@config.pretend = true
|
103
|
+
assert @config.pretend?
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_profile?
|
107
|
+
refute @config.profile?
|
108
|
+
|
109
|
+
@config.profile = true
|
110
|
+
assert @config.profile?
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_future_parser?
|
114
|
+
refute @config.future_parser?
|
115
|
+
|
116
|
+
@config.future_parser = true
|
117
|
+
assert @config.future_parser?
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_skip_puppetfile?
|
121
|
+
refute @config.skip_puppetfile?
|
122
|
+
|
123
|
+
@config.skip_puppetfile = true
|
124
|
+
assert @config.skip_puppetfile?
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_projects
|
128
|
+
files = Dir["#{@config.repodir}/modules/projects/manifests/*.pp"]
|
129
|
+
assert_equal files.size, @config.projects.size
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_puppetdir
|
133
|
+
assert_equal "/tmp/boxen/puppet", @config.puppetdir
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_puppetdir_env_var
|
137
|
+
val = ENV["BOXEN_PUPPET_DIR"]
|
138
|
+
|
139
|
+
ENV["BOXEN_PUPPET_DIR"] = "foo"
|
140
|
+
assert_equal "foo", @config.puppetdir
|
141
|
+
|
142
|
+
ENV["BOXEN_PUPPET_DIR"] = val
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_ghurl
|
146
|
+
@config.ghurl = "https://git.foo.com"
|
147
|
+
assert_equal "https://git.foo.com", @config.ghurl
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_ghurl_blank
|
151
|
+
assert_equal "https://github.com", @config.ghurl
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_gheurl_env_var
|
155
|
+
val = ENV['BOXEN_GITHUB_ENTERPRISE_URL']
|
156
|
+
|
157
|
+
ENV['BOXEN_GITHUB_ENTERPRISE_URL'] = 'https://git.foo.com'
|
158
|
+
assert_equal "https://git.foo.com", @config.ghurl
|
159
|
+
|
160
|
+
ENV['BOXEN_GITHUB_ENTERPRISE_URL'] = val
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_enterprise_true
|
164
|
+
@config.ghurl = "https://git.foo.com"
|
165
|
+
assert @config.enterprise?
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_enterprise_false
|
169
|
+
assert @config.enterprise? == false
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_repotemplate
|
173
|
+
@config.repotemplate = 'https://git.foo.com/%s'
|
174
|
+
assert_equal 'https://git.foo.com/%s', @config.repotemplate
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_repotemplate_blank
|
178
|
+
assert_equal 'https://github.com/%s', @config.repotemplate
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_repotemplate_env_var
|
182
|
+
val = ENV['BOXEN_REPO_URL_TEMPLATE']
|
183
|
+
|
184
|
+
ENV['BOXEN_REPO_URL_TEMPLATE'] = 'https://git.foo.com/%s'
|
185
|
+
assert_equal 'https://git.foo.com/%s', @config.repotemplate
|
186
|
+
|
187
|
+
ENV['BOXEN_REPO_URL_TEMPLATE'] = val
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_repodir
|
191
|
+
@config.repodir = nil
|
192
|
+
assert_equal Dir.pwd, @config.repodir
|
193
|
+
|
194
|
+
@config.repodir = "foo"
|
195
|
+
assert_equal "foo", @config.repodir
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_repodir_env_var
|
199
|
+
@config.repodir = nil
|
200
|
+
|
201
|
+
val = ENV["BOXEN_REPO_DIR"]
|
202
|
+
|
203
|
+
ENV["BOXEN_REPO_DIR"] = "foo"
|
204
|
+
assert_equal "foo", @config.repodir
|
205
|
+
|
206
|
+
ENV["BOXEN_REPO_DIR"] = val
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_reponame
|
210
|
+
@config.reponame = "something/explicit"
|
211
|
+
assert_equal "something/explicit", @config.reponame
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_reponame_env_var
|
215
|
+
val = ENV["BOXEN_REPO_NAME"]
|
216
|
+
|
217
|
+
ENV["BOXEN_REPO_NAME"] = "env/var"
|
218
|
+
assert_equal "env/var", @config.reponame
|
219
|
+
|
220
|
+
ENV["BOXEN_REPO_NAME"] = val
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_reponame_git_config
|
224
|
+
@config.expects(:"`").with("git config remote.origin.url").
|
225
|
+
returns "https://github.com/some-org/our-boxen\n"
|
226
|
+
|
227
|
+
assert_equal "some-org/our-boxen", @config.reponame
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_reponame_git_config_ghurl
|
231
|
+
@config.ghurl = 'https://git.foo.com'
|
232
|
+
@config.expects(:"`").with("git config remote.origin.url").
|
233
|
+
returns "https://git.foo.com/some-org/our-boxen\n"
|
234
|
+
|
235
|
+
assert_equal "some-org/our-boxen", @config.reponame
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_reponame_git_config_git_protocol
|
239
|
+
@config.expects(:"`").with("git config remote.origin.url").
|
240
|
+
returns "git@github.com:some-org/our-boxen.git\n"
|
241
|
+
|
242
|
+
assert_equal "some-org/our-boxen", @config.reponame
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_reponame_git_config_git_protocol_ghurl
|
246
|
+
@config.ghurl = 'https://git.foo.com'
|
247
|
+
@config.expects(:"`").with("git config remote.origin.url").
|
248
|
+
returns "git@git.foo.com:some-org/our-boxen.git\n"
|
249
|
+
|
250
|
+
assert_equal "some-org/our-boxen", @config.reponame
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_reponame_git_config_bad_exit
|
254
|
+
@config.expects(:"`").with("git config remote.origin.url").returns ""
|
255
|
+
$?.expects(:success?).returns false
|
256
|
+
|
257
|
+
assert_nil @config.reponame
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_reponame_git_config_bad_url
|
261
|
+
@config.expects(:"`").with("git config remote.origin.url").
|
262
|
+
returns "https://spumco.com/some-org/our-boxen\n"
|
263
|
+
$?.expects(:success?).returns true
|
264
|
+
|
265
|
+
assert_nil @config.reponame
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_reponame_git_config_bad_url_git_protocol
|
269
|
+
@config.expects(:"`").with("git config remote.origin.url").
|
270
|
+
returns "git@spumco.com:some-org/our-boxen.git\n"
|
271
|
+
$?.expects(:success?).returns true
|
272
|
+
|
273
|
+
assert_nil @config.reponame
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_reponame_git_config_git_extension
|
277
|
+
@config.expects(:"`").with("git config remote.origin.url").
|
278
|
+
returns "https://github.com/some-org/our-boxen.git\n"
|
279
|
+
$?.expects(:success?).returns true
|
280
|
+
|
281
|
+
assert_equal "some-org/our-boxen", @config.reponame
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_reponame_git_config_git_extension_ghurl
|
285
|
+
@config.ghurl = 'https://git.foo.com'
|
286
|
+
@config.expects(:"`").with("git config remote.origin.url").
|
287
|
+
returns "https://git.foo.com/some-org/our-boxen.git\n"
|
288
|
+
$?.expects(:success?).returns true
|
289
|
+
|
290
|
+
assert_equal "some-org/our-boxen", @config.reponame
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_srcdir
|
294
|
+
val = ENV["BOXEN_SRC_DIR"]
|
295
|
+
ENV["BOXEN_SRC_DIR"] = nil
|
296
|
+
|
297
|
+
@config.expects(:user).returns "foo"
|
298
|
+
assert_equal "/Users/foo/src", @config.srcdir
|
299
|
+
|
300
|
+
@config.srcdir = "elsewhere"
|
301
|
+
assert_equal "elsewhere", @config.srcdir
|
302
|
+
|
303
|
+
ENV["BOXEN_SRC_DIR"] = val
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_srcdir_env_var
|
307
|
+
@config.srcdir = nil
|
308
|
+
|
309
|
+
val = ENV["BOXEN_SRC_DIR"]
|
310
|
+
|
311
|
+
ENV["BOXEN_SRC_DIR"] = "Projects"
|
312
|
+
assert_equal "Projects", @config.srcdir
|
313
|
+
|
314
|
+
ENV["BOXEN_SRC_DIR"] = val
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_stealth?
|
318
|
+
refute @config.stealth?
|
319
|
+
|
320
|
+
@config.stealth = true
|
321
|
+
assert @config.stealth?
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_stealth_env_var
|
325
|
+
val = ENV["BOXEN_NO_ISSUE"]
|
326
|
+
|
327
|
+
ENV["BOXEN_NO_ISSUE"] = "1"
|
328
|
+
assert @config.stealth?
|
329
|
+
|
330
|
+
ENV["BOXEN_NO_ISSUE"] = val
|
331
|
+
end
|
332
|
+
|
333
|
+
def test_token
|
334
|
+
assert_nil @config.token
|
335
|
+
|
336
|
+
@config.token = "foo"
|
337
|
+
assert_equal "foo", @config.token
|
338
|
+
end
|
339
|
+
|
340
|
+
def test_user
|
341
|
+
ENV["USER"] = "foo"
|
342
|
+
assert_equal "foo", @config.user
|
343
|
+
|
344
|
+
@config.user = "bar"
|
345
|
+
assert_equal "bar", @config.user
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_api
|
349
|
+
@config.token = token = "s3kr!7"
|
350
|
+
|
351
|
+
api = Object.new
|
352
|
+
Octokit::Client.expects(:new).with(:login => token, :password => 'x-oauth-basic').once.returns(api)
|
353
|
+
|
354
|
+
assert_equal api, @config.api
|
355
|
+
assert_equal api, @config.api # This extra call plus the `once` on the expectation is for the ivar cache.
|
356
|
+
end
|
357
|
+
|
358
|
+
def test_s3host
|
359
|
+
val = ENV["BOXEN_S3_HOST"]
|
360
|
+
ENV["BOXEN_S3_HOST"] = nil
|
361
|
+
|
362
|
+
assert_equal "s3.amazonaws.com", @config.s3host
|
363
|
+
|
364
|
+
@config.s3host = "example.com"
|
365
|
+
assert_equal "example.com", @config.s3host
|
366
|
+
ensure
|
367
|
+
ENV["BOXEN_S3_HOST"] = val
|
368
|
+
end
|
369
|
+
|
370
|
+
def test_s3host_env_var
|
371
|
+
val = ENV["BOXEN_S3_HOST"]
|
372
|
+
|
373
|
+
ENV["BOXEN_S3_HOST"] = "example.com"
|
374
|
+
assert_equal "example.com", @config.s3host
|
375
|
+
|
376
|
+
ensure
|
377
|
+
ENV["BOXEN_S3_HOST"] = val
|
378
|
+
end
|
379
|
+
|
380
|
+
def test_s3bucket
|
381
|
+
val = ENV["BOXEN_S3_BUCKET"]
|
382
|
+
ENV["BOXEN_S3_BUCKET"] = nil
|
383
|
+
|
384
|
+
assert_equal "boxen-downloads", @config.s3bucket
|
385
|
+
|
386
|
+
@config.s3bucket = "my-bucket"
|
387
|
+
assert_equal "my-bucket", @config.s3bucket
|
388
|
+
ensure
|
389
|
+
ENV["BOXEN_S3_BUCKET"] = val
|
390
|
+
end
|
391
|
+
|
392
|
+
def test_s3host_env_var
|
393
|
+
val = ENV["BOXEN_S3_BUCKET"]
|
394
|
+
|
395
|
+
ENV["BOXEN_S3_BUCKET"] = "my-bucket"
|
396
|
+
assert_equal "my-bucket", @config.s3bucket
|
397
|
+
ensure
|
398
|
+
ENV["BOXEN_S3_BUCKET"] = val
|
399
|
+
end
|
400
|
+
end
|