pipe2me-client 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ module Pipe2me::Tunnel::OpenSSL
2
+ HTTP = Pipe2me::HTTP
3
+
4
+ SSL_KEY = Pipe2me::Tunnel::SSL_KEY
5
+ SSL_CERT = Pipe2me::Tunnel::SSL_CERT
6
+
7
+ def openssl_conf
8
+ File.join(File.dirname(__FILE__), "openssl.conf")
9
+ end
10
+
11
+ # create openssl private key and cert signing request.
12
+ def ssl_keygen
13
+ sys! "openssl",
14
+ "req", "-config", openssl_conf,
15
+ "-new", "-nodes",
16
+ "-keyout", SSL_KEY,
17
+ "-out", "#{SSL_KEY}.csr",
18
+ "-subj", "/C=de/ST=ne/L=Berlin/O=pipe2me/CN=#{config.fqdn}",
19
+ "-days", "7300"
20
+ end
21
+
22
+ # send cert signing request to server and receive certificate
23
+ def ssl_certsign
24
+ cert = HTTP.post!("#{url}/cert.pem", File.read("#{SSL_KEY}.csr"), {'Content-Type' =>'text/plain'})
25
+ UI.debug "received certificate:\n#{cert}"
26
+
27
+ File.atomic_write SSL_CERT, cert
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ module Pipe2me::Tunnel::SSH
2
+ HTTP = Pipe2me::HTTP
3
+
4
+ SSH_PUBKEY = Pipe2me::Tunnel::SSH_PUBKEY
5
+ SSH_PRIVKEY = Pipe2me::Tunnel::SSH_PRIVKEY
6
+
7
+ def ssh_keygen
8
+ sh! "ssh-keygen -t rsa -N '' -C #{config.fqdn} -f pipe2me.id_rsa >&2"
9
+ sh! "chmod 600 pipe2me.id_rsa*"
10
+ HTTP.post!("#{url}/id_rsa.pub", File.read(SSH_PUBKEY), {'Content-Type' =>'text/plain'})
11
+ rescue
12
+ FileUtils.rm_rf SSH_PRIVKEY
13
+ FileUtils.rm_rf SSH_PUBKEY
14
+ raise
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ module Pipe2me
2
+ VERSION = "0.2.0"
3
+ BANNER = "pipe2.me command line client V#{Pipe2me::VERSION}; (c) The kink team, 2013, 2014."
4
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env roundup
2
+ describe "Is roundup working?"
3
+
4
+ it_exits_non_zero() {
5
+ roundup=$(which roundup)
6
+ test "" != $roundup
7
+ }
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env roundup
2
+ describe "fails on invalid and missing auth"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ it_fails_on_invalid_auth() {
7
+ ! $pipe2me setup --server $pipe2me_server --auth $pipe2me_token.invalid
8
+ }
9
+
10
+ it_fails_on_missing_auth_token() {
11
+ ! $pipe2me setup --server $pipe2me_server
12
+ }
data/test/env-test.sh ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env roundup
2
+ describe "show pipe2me environment"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ it_start_a_tunnel() {
7
+ fqdn=$($pipe2me setup --server $pipe2me_server --auth $pipe2me_token)
8
+ $pipe2me env > env
9
+ echo "== env is ============="
10
+ cat env
11
+ echo "== env done ============="
12
+
13
+ cat env | grep PIPE2ME_SERVER
14
+ cat env | grep PIPE2ME_TOKEN
15
+ cat env | grep PIPE2ME_FQDN
16
+ cat env | grep PIPE2ME_URLS_0
17
+ cat env | grep PIPE2ME_TUNNEL
18
+ ! (cat env | grep PIPE2ME_URLS_1)
19
+
20
+ # can we source the env?
21
+ eval $($pipe2me env)
22
+ echo $PIPE2ME_URLS_0 | grep http
23
+ }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env roundup
2
+ describe "setup and starts tunnels in foreman mode"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ it_works_with_foreman() {
7
+ false [TODO] It setup and starts tunnels in foreman mode
8
+ # i.e. pipe2me setup
9
+ # pipe2me echo
10
+ # ...
11
+ }
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env roundup
2
+ describe "setup and starts tunnels in foreman mode"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ it_works_with_monitrc() {
7
+ false [TODO] It setup and starts tunnels in monitrc mode
8
+ # i.e. pipe2me setup
9
+ # pipe2me monitrc
10
+ # pipe2me monit start all
11
+ # ...
12
+ }
13
+
14
+ it_creates_a_monitrc_file() {
15
+ ! [ -e pipe2me.monitrc ]
16
+ fqdn=$($pipe2me setup --server $pipe2me_server --auth $pipe2me_token)
17
+
18
+ $pipe2me monitrc
19
+ [ -e pipe2me.monitrc ]
20
+
21
+ # The file is 0600
22
+ ls -l pipe2me.monitrc | grep -e "-rw-------"
23
+ }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env roundup
2
+ describe "openssl tests"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ # setup creates and signs openssl credentials
7
+ it_sets_up_openssl_certs() {
8
+ fqdn=$($pipe2me setup --server $pipe2me_server --auth $pipe2me_token)
9
+ test -f pipe2me.openssl.priv
10
+ cat pipe2me.openssl.priv | grep "BEGIN RSA PRIVATE KEY"
11
+
12
+ test -f pipe2me.openssl.cert
13
+ cat pipe2me.openssl.cert | grep "BEGIN CERTIFICATE"
14
+
15
+ # verify cert name
16
+ openssl x509 -in pipe2me.openssl.cert -text | grep CN=$fqdn
17
+ }
18
+
19
+ it_cannot_sign_other_certs() {
20
+ false [TODO] A certificate cannot be used to sign other certificates
21
+ }
22
+
23
+ it_cannot_sign_fake_certs() {
24
+ false [TODO] A client cannot ask the server to sign certs with different names
25
+ }
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env roundup
2
+ describe 'a HTTP(s) connection to subdomain.$pipe2me_server redirects to subdomain.$pipe2me_server:port'
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ it_redirects_https_connections() {
7
+ false [TODO] 'redirects https://subdomain.$pipe2me_server to https://subdomain.$pipe2me_server:port'
8
+ }
9
+
10
+ it_redirects_http_connections() {
11
+ false [TODO] 'redirects http://subdomain.$pipe2me_server to http://subdomain.$pipe2me_server:port'
12
+ }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env roundup
2
+ describe "tunnel setup"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ # setup a tunnel
7
+ it_sets_up_tunnels() {
8
+ fqdn=$($pipe2me setup --server $pipe2me_server --auth $pipe2me_token)
9
+
10
+ # pipe2me setup --server $pipe2me_server returns the fqdn of the subdomain and nothing else
11
+ test 1 -eq $(echo $fqdn | wc -l)
12
+
13
+ # The subdomain is actually a subdomain.
14
+ echo $fqdn | grep \.pipe2\.dev
15
+
16
+ # Cannot setup a second tunnel in the same directory.
17
+ ! $pipe2me setup --server $pipe2me_server --auth $pipe2me_token
18
+ }
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env roundup
2
+ describe "ssh key creation"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ it_sets_up_ssh_identity() {
7
+ fqdn=$($pipe2me setup --server $pipe2me_server --auth $pipe2me_token)
8
+ test -f pipe2me.id_rsa.pub
9
+ test -f pipe2me.id_rsa
10
+
11
+ # identity must contain $fqdn
12
+ cat pipe2me.id_rsa.pub | grep $fqdn
13
+ }
@@ -0,0 +1,2 @@
1
+ pipe2me_server=http://pipe2.dev:8080
2
+ pipe2me_token=test@test.kinko.me
@@ -0,0 +1,24 @@
1
+ # The pipe2me binary to test
2
+ pipe2me=$(cd $(dirname $1)/../bin && pwd)/pipe2me
3
+ # pipe2me_server=http://test.pipe2.me:8080
4
+
5
+ # Load test scenario settings
6
+ echo "Load $TEST_ENV test settings"
7
+ if [ -z "$TEST_ENV" ]; then
8
+ TEST_ENV=debug
9
+ fi
10
+
11
+ . $(dirname $1)/testhelper.${TEST_ENV}
12
+
13
+ # A temporary workspace to run tests.
14
+ scrub=$(cd $(dirname $1)/../tmp && pwd)/scrub
15
+
16
+ before() {
17
+ mkdir -p $scrub
18
+ cd $scrub
19
+ }
20
+
21
+ after() {
22
+ cd ..
23
+ rm -rf $scrub
24
+ }
@@ -0,0 +1,2 @@
1
+ pipe2me_server=http://pipe2.dev:8080
2
+ pipe2me_token=test@test.kinko.me
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env roundup
2
+ describe "-h shows help"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ it_shows_help() {
7
+ help=$($pipe2me -h)
8
+ test "" != "$help"
9
+ }
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pipe2me-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - radiospiel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: foreman
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simple-ui
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: pipe2.me command line client V0.2.0; (c) The kink team, 2013, 2014.
70
+ email: contact@kinko.me
71
+ executables:
72
+ - pipe2me
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - README.mdown
77
+ - bin/pipe2me
78
+ - lib/pipe2me.rb
79
+ - lib/pipe2me/cli-foreman.rb
80
+ - lib/pipe2me/cli-monit.rb
81
+ - lib/pipe2me/cli.rb
82
+ - lib/pipe2me/config.rb
83
+ - lib/pipe2me/ext/file_ext.rb
84
+ - lib/pipe2me/ext/http.rb
85
+ - lib/pipe2me/ext/shell_format.rb
86
+ - lib/pipe2me/ext/sys.rb
87
+ - lib/pipe2me/tunnel.rb
88
+ - lib/pipe2me/tunnel/commands.rb
89
+ - lib/pipe2me/tunnel/echo/http
90
+ - lib/pipe2me/tunnel/echo/https
91
+ - lib/pipe2me/tunnel/openssl.conf
92
+ - lib/pipe2me/tunnel/openssl.rb
93
+ - lib/pipe2me/tunnel/ssh.rb
94
+ - lib/pipe2me/version.rb
95
+ - test/000-roundup-test.sh
96
+ - test/auth-token-test.sh
97
+ - test/env-test.sh
98
+ - test/foreman-test.sh
99
+ - test/monitrc-test.sh
100
+ - test/opensslkey-test.sh
101
+ - test/redirection-test.sh
102
+ - test/setup-test.sh
103
+ - test/sshkey-test.sh
104
+ - test/testhelper.debug
105
+ - test/testhelper.inc
106
+ - test/testhelper.release
107
+ - test/version-test.sh
108
+ homepage: https://github.com/kinko/pipe2me-client
109
+ licenses: []
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.2.1
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: pipe2.me command line client V0.2.0; (c) The kink team, 2013, 2014.
131
+ test_files: []