duse 0.0.2
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.
- checksums.yaml +15 -0
- data/.gitignore +35 -0
- data/.rspec +2 -0
- data/.travis.yml +13 -0
- data/Gemfile +13 -0
- data/LICENSE +22 -0
- data/README.md +89 -0
- data/Rakefile +11 -0
- data/bin/duse +8 -0
- data/duse.gemspec +22 -0
- data/lib/duse.rb +10 -0
- data/lib/duse/cli.rb +104 -0
- data/lib/duse/cli/account.rb +20 -0
- data/lib/duse/cli/account_confirm.rb +22 -0
- data/lib/duse/cli/account_info.rb +18 -0
- data/lib/duse/cli/account_password.rb +14 -0
- data/lib/duse/cli/account_password_change.rb +30 -0
- data/lib/duse/cli/account_password_reset.rb +20 -0
- data/lib/duse/cli/account_resend_confirmation.rb +20 -0
- data/lib/duse/cli/account_update.rb +25 -0
- data/lib/duse/cli/api_command.rb +33 -0
- data/lib/duse/cli/cli_config.rb +54 -0
- data/lib/duse/cli/command.rb +202 -0
- data/lib/duse/cli/config.rb +16 -0
- data/lib/duse/cli/help.rb +23 -0
- data/lib/duse/cli/key_helper.rb +84 -0
- data/lib/duse/cli/login.rb +27 -0
- data/lib/duse/cli/meta_command.rb +12 -0
- data/lib/duse/cli/parser.rb +43 -0
- data/lib/duse/cli/password_helper.rb +17 -0
- data/lib/duse/cli/register.rb +45 -0
- data/lib/duse/cli/secret.rb +19 -0
- data/lib/duse/cli/secret_add.rb +38 -0
- data/lib/duse/cli/secret_generator.rb +10 -0
- data/lib/duse/cli/secret_get.rb +40 -0
- data/lib/duse/cli/secret_list.rb +20 -0
- data/lib/duse/cli/secret_remove.rb +19 -0
- data/lib/duse/cli/secret_update.rb +44 -0
- data/lib/duse/cli/share_with_user.rb +53 -0
- data/lib/duse/cli/version.rb +12 -0
- data/lib/duse/client/config.rb +36 -0
- data/lib/duse/client/entity.rb +87 -0
- data/lib/duse/client/namespace.rb +112 -0
- data/lib/duse/client/secret.rb +69 -0
- data/lib/duse/client/session.rb +128 -0
- data/lib/duse/client/user.rb +23 -0
- data/lib/duse/encryption.rb +39 -0
- data/lib/duse/version.rb +3 -0
- data/spec/cli/cli_config_spec.rb +49 -0
- data/spec/cli/commands/account_spec.rb +45 -0
- data/spec/cli/commands/config_spec.rb +17 -0
- data/spec/cli/commands/login_spec.rb +51 -0
- data/spec/cli/commands/register_spec.rb +38 -0
- data/spec/cli/commands/secret_spec.rb +142 -0
- data/spec/client/secret_marshaller_spec.rb +32 -0
- data/spec/client/secret_spec.rb +96 -0
- data/spec/client/user_spec.rb +105 -0
- data/spec/spec_helper.rb +70 -0
- data/spec/support/helpers.rb +43 -0
- data/spec/support/mock_api.rb +142 -0
- metadata +159 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
RSpec.describe Duse::Client::User do
|
2
|
+
before :each do
|
3
|
+
Duse.config = Duse::CLIConfig.new({ 'uri' => 'https://example.com/' })
|
4
|
+
end
|
5
|
+
|
6
|
+
def stub_create_user
|
7
|
+
payload = {
|
8
|
+
'id' => 2,
|
9
|
+
'username' => 'flower-pot',
|
10
|
+
'email' => 'flower-pot@example.org',
|
11
|
+
'public_key' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCftZvHkB6uKWVDvrIzmy2p496H\nv9PD/hhRk+DSXcE/CPtRmvYZzbWbbBup9hkvhyH/P1O5EF8KSZm4Cdnz6p37idTe\nNdlaH9cRFV2wc2A/hbg2kaISxrDxUqRbywBE9NOBSjXu2wRpy0TMo85eM2A0E2ET\n2XM6tZcuwFULX6bl8QIDAQAB\n-----END PUBLIC KEY-----\n",
|
12
|
+
'url' => 'https://example.com/users/2'
|
13
|
+
}.to_json
|
14
|
+
|
15
|
+
stub_request(:post, "https://example.com/users").
|
16
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
17
|
+
to_return(status: 201, body: payload, headers: {})
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.all' do
|
21
|
+
it 'returns an array of users' do
|
22
|
+
stub_get_users
|
23
|
+
users = Duse::User.all
|
24
|
+
|
25
|
+
expect(users.length).to eq 3
|
26
|
+
expect(users.class).to be Array
|
27
|
+
users.each do |user|
|
28
|
+
expect(user.class).to be Duse::Client::User
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.create' do
|
34
|
+
it 'creates correct user entity from json create response' do
|
35
|
+
stub_create_user
|
36
|
+
public_key = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCftZvHkB6uKWVDvrIzmy2p496H\nv9PD/hhRk+DSXcE/CPtRmvYZzbWbbBup9hkvhyH/P1O5EF8KSZm4Cdnz6p37idTe\nNdlaH9cRFV2wc2A/hbg2kaISxrDxUqRbywBE9NOBSjXu2wRpy0TMo85eM2A0E2ET\n2XM6tZcuwFULX6bl8QIDAQAB\n-----END PUBLIC KEY-----\n"
|
37
|
+
|
38
|
+
user = Duse::User.create(
|
39
|
+
username: 'flower-pot',
|
40
|
+
email: 'flower-pot@example.org',
|
41
|
+
password: 'Passw0rd!',
|
42
|
+
password_confirmation: 'Passw0rd!',
|
43
|
+
public_key: public_key
|
44
|
+
)
|
45
|
+
|
46
|
+
expect(user.username).to eq 'flower-pot'
|
47
|
+
expect(user.email).to eq 'flower-pot@example.org'
|
48
|
+
expect(user.public_key.to_s).to eq public_key
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '.find' do
|
53
|
+
context 'own user' do
|
54
|
+
it 'creates the correct entity when requesting own user' do
|
55
|
+
stub_user_me_get
|
56
|
+
public_key = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCftZvHkB6uKWVDvrIzmy2p496H\nv9PD/hhRk+DSXcE/CPtRmvYZzbWbbBup9hkvhyH/P1O5EF8KSZm4Cdnz6p37idTe\nNdlaH9cRFV2wc2A/hbg2kaISxrDxUqRbywBE9NOBSjXu2wRpy0TMo85eM2A0E2ET\n2XM6tZcuwFULX6bl8QIDAQAB\n-----END PUBLIC KEY-----\n"
|
57
|
+
|
58
|
+
user = Duse::User.find 'me'
|
59
|
+
|
60
|
+
expect(user.username).to eq 'flower-pot'
|
61
|
+
expect(user.email).to eq 'flower-pot@example.org'
|
62
|
+
expect(user.public_key.to_s).to eq public_key
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'server user' do
|
67
|
+
it 'creates the correct entity when requesting the server user' do
|
68
|
+
stub_server_user_get
|
69
|
+
public_key = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC8Z1K4aCksOb6rsbKNcF4fNcN\n1Tbyv+ids751YvmfU2WHDXB3wIVoN1YRdb8Dk8608YlGAAqVaGVwfgYdyLMppIGs\nglZIMjwZFM2F84T4swKOEJJx6o3ZCRnP9ZQcceqzcIuTjiIqC7xu+QOvtADAMW68\nzZIpFOHjjiuxkA7PQQIDAQAB\n-----END PUBLIC KEY-----\n"
|
70
|
+
|
71
|
+
user = Duse::User.find 'server'
|
72
|
+
|
73
|
+
expect(user.username).to eq 'server'
|
74
|
+
expect(user.email).to eq 'server@localhost'
|
75
|
+
expect(user.public_key.to_s).to eq public_key
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'any user' do
|
80
|
+
it 'creates the correct entity when requesting a specific user' do
|
81
|
+
stub_get_other_user
|
82
|
+
public_key = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTF2gEqXRy2hJ6+xjj6IbzAgHG\nHvnLNnZlwkYm0ZV89uiPxL9mKYNiW4KA1azZlvJZviTF4218WAwO1IGIH+PppdXF\nIK8vmB6IIaQcO4UTjSA6ZTn8Uwf1fwS4EAuL3Zr3IVdjVYQ4+/ZNtmSyVMmo+7zP\nyOa31hUhDNYrJO1iEQIDAQAB\n-----END PUBLIC KEY-----\n"
|
83
|
+
|
84
|
+
user = Duse::User.find 3
|
85
|
+
|
86
|
+
expect(user.username).to eq 'adracus'
|
87
|
+
expect(user.email).to eq 'adracus@example.org'
|
88
|
+
expect(user.public_key.to_s).to eq public_key
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'reloads an entity when necessary' do
|
94
|
+
stub_get_users
|
95
|
+
stub_get_other_user
|
96
|
+
users = Duse::User.all
|
97
|
+
user = users.last
|
98
|
+
|
99
|
+
expect(users.length).to eq 3
|
100
|
+
expect(user.attributes['public_key']).to be nil
|
101
|
+
expect(user.username).to eq 'adracus'
|
102
|
+
expect(user.email).to eq 'adracus@example.org'
|
103
|
+
expect(user.public_key.to_s).to eq "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTF2gEqXRy2hJ6+xjj6IbzAgHG\nHvnLNnZlwkYm0ZV89uiPxL9mKYNiW4KA1azZlvJZviTF4218WAwO1IGIH+PppdXF\nIK8vmB6IIaQcO4UTjSA6ZTn8Uwf1fwS4EAuL3Zr3IVdjVYQ4+/ZNtmSyVMmo+7zP\nyOa31hUhDNYrJO1iEQIDAQAB\n-----END PUBLIC KEY-----\n"
|
104
|
+
end
|
105
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider
|
11
|
+
# making a separate helper file that requires the additional dependencies and
|
12
|
+
# performs the additional setup, and require it from the spec files that
|
13
|
+
# actually need it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
|
20
|
+
unless ENV['CI']
|
21
|
+
require 'simplecov'
|
22
|
+
SimpleCov.start
|
23
|
+
end
|
24
|
+
|
25
|
+
if ENV['CI']
|
26
|
+
require 'coveralls'
|
27
|
+
Coveralls.wear!
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'fileutils'
|
31
|
+
require 'fakefs/spec_helpers'
|
32
|
+
|
33
|
+
require 'support/helpers'
|
34
|
+
require 'support/mock_api'
|
35
|
+
require 'duse'
|
36
|
+
require 'duse/cli'
|
37
|
+
|
38
|
+
RSpec.configure do |config|
|
39
|
+
# rspec-expectations config goes here. You can use an alternate
|
40
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
41
|
+
# assertions if you prefer.
|
42
|
+
config.expect_with :rspec do |expectations|
|
43
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
44
|
+
# and `failure_message` of custom matchers include text for helper methods
|
45
|
+
# defined using `chain`, e.g.:
|
46
|
+
# be_bigger_than(2).and_smaller_than(4).description # => "be bigger than 2
|
47
|
+
# and smaller than 4" ...rather than: # => "be bigger than 2"
|
48
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
49
|
+
end
|
50
|
+
|
51
|
+
config.include Helpers
|
52
|
+
config.include MockAPI
|
53
|
+
config.include FakeFS::SpecHelpers
|
54
|
+
|
55
|
+
config.before :each do
|
56
|
+
Duse.config = nil
|
57
|
+
end
|
58
|
+
|
59
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
60
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
61
|
+
config.mock_with :rspec do |mocks|
|
62
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
63
|
+
# a real object. This is generally recommended, and will default to
|
64
|
+
# `true` in RSpec 4.
|
65
|
+
mocks.verify_partial_doubles = true
|
66
|
+
end
|
67
|
+
|
68
|
+
config.order = :random
|
69
|
+
Kernel.srand config.seed
|
70
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module Helpers
|
6
|
+
attr_reader :last_run
|
7
|
+
|
8
|
+
def capture
|
9
|
+
_stdout, $stdout = $stdout, StringIO.new
|
10
|
+
_stderr, $stderr = $stderr, StringIO.new
|
11
|
+
_stdin, $stdin = $stdin, StringIO.new
|
12
|
+
yield
|
13
|
+
capture_result(true)
|
14
|
+
rescue SystemExit => e
|
15
|
+
capture_result(e.success?)
|
16
|
+
ensure
|
17
|
+
$stdout = _stdout if _stdout
|
18
|
+
$stderr = _stderr if _stderr
|
19
|
+
$stdin = _stdin if _stdin
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_cli(*args)
|
23
|
+
capture do
|
24
|
+
yield $stdin if block_given?
|
25
|
+
$stdin.rewind
|
26
|
+
Duse::CLI.run(*args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def stderr
|
31
|
+
last_run.err if last_run
|
32
|
+
end
|
33
|
+
|
34
|
+
def stdout
|
35
|
+
last_run.out if last_run
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def capture_result(success)
|
41
|
+
@last_run = OpenStruct.new(:out => $stdout.string, :in => $stdin.string, :err => $stderr.string, :success? => success)
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'webmock/rspec'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module MockAPI
|
5
|
+
def stub_get_users
|
6
|
+
payload = [{
|
7
|
+
'id' => 1,
|
8
|
+
'username' => 'server',
|
9
|
+
'email' => 'server@localhost',
|
10
|
+
'url' => 'https://example.com/users/1'
|
11
|
+
}, {
|
12
|
+
'id' => 2,
|
13
|
+
'username' => 'flower-pot',
|
14
|
+
'email' => 'flower-pot@example.org',
|
15
|
+
'url' => 'https://example.com/users/2'
|
16
|
+
}, {
|
17
|
+
'id' => 3,
|
18
|
+
'username' => 'adracus',
|
19
|
+
'email' => 'adracus@example.org',
|
20
|
+
'url' => 'https://example.com/users/3'
|
21
|
+
}].to_json
|
22
|
+
stub_request(:get, "https://example.com/users").
|
23
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
24
|
+
to_return(status: 200, body: payload, headers: {})
|
25
|
+
end
|
26
|
+
|
27
|
+
def stub_user_me_get
|
28
|
+
payload = {
|
29
|
+
'id' => 2,
|
30
|
+
'username' => 'flower-pot',
|
31
|
+
'email' => 'flower-pot@example.org',
|
32
|
+
'public_key' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCftZvHkB6uKWVDvrIzmy2p496H\nv9PD/hhRk+DSXcE/CPtRmvYZzbWbbBup9hkvhyH/P1O5EF8KSZm4Cdnz6p37idTe\nNdlaH9cRFV2wc2A/hbg2kaISxrDxUqRbywBE9NOBSjXu2wRpy0TMo85eM2A0E2ET\n2XM6tZcuwFULX6bl8QIDAQAB\n-----END PUBLIC KEY-----\n",
|
33
|
+
'url' => 'https://example.com/users/2'
|
34
|
+
}.to_json
|
35
|
+
|
36
|
+
stub_request(:get, "https://example.com/users/me").
|
37
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
38
|
+
to_return(status: 200, body: payload)
|
39
|
+
end
|
40
|
+
|
41
|
+
def stub_server_user_get
|
42
|
+
payload = {
|
43
|
+
'id' => 1,
|
44
|
+
'username' => 'server',
|
45
|
+
'email' => 'server@localhost',
|
46
|
+
'public_key' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC8Z1K4aCksOb6rsbKNcF4fNcN\n1Tbyv+ids751YvmfU2WHDXB3wIVoN1YRdb8Dk8608YlGAAqVaGVwfgYdyLMppIGs\nglZIMjwZFM2F84T4swKOEJJx6o3ZCRnP9ZQcceqzcIuTjiIqC7xu+QOvtADAMW68\nzZIpFOHjjiuxkA7PQQIDAQAB\n-----END PUBLIC KEY-----\n",
|
47
|
+
'url' => 'https://example.com/users/1'
|
48
|
+
}.to_json
|
49
|
+
|
50
|
+
stub_request(:get, "https://example.com/users/server").
|
51
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
52
|
+
to_return(status: 200, body: payload)
|
53
|
+
end
|
54
|
+
|
55
|
+
def stub_get_other_user
|
56
|
+
payload = {
|
57
|
+
'id' => 3,
|
58
|
+
'username' => 'adracus',
|
59
|
+
'email' => 'adracus@example.org',
|
60
|
+
'public_key' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTF2gEqXRy2hJ6+xjj6IbzAgHG\nHvnLNnZlwkYm0ZV89uiPxL9mKYNiW4KA1azZlvJZviTF4218WAwO1IGIH+PppdXF\nIK8vmB6IIaQcO4UTjSA6ZTn8Uwf1fwS4EAuL3Zr3IVdjVYQ4+/ZNtmSyVMmo+7zP\nyOa31hUhDNYrJO1iEQIDAQAB\n-----END PUBLIC KEY-----\n",
|
61
|
+
'url' => 'https://example.com/users/3'
|
62
|
+
}.to_json
|
63
|
+
stub_request(:get, "https://example.com/users/3").
|
64
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
65
|
+
to_return(status: 200, body: payload, headers: {})
|
66
|
+
end
|
67
|
+
|
68
|
+
def stub_get_secrets
|
69
|
+
payload = [{
|
70
|
+
'id' => 1,
|
71
|
+
'title' => 'test',
|
72
|
+
'url' => 'http://example.com/secrets/1'
|
73
|
+
}].to_json
|
74
|
+
stub_request(:get, "https://example.com/secrets").
|
75
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
76
|
+
to_return(status: 200, body: payload)
|
77
|
+
end
|
78
|
+
|
79
|
+
def stub_secret_get
|
80
|
+
payload = {
|
81
|
+
'id' => 1,
|
82
|
+
'title' => 'test',
|
83
|
+
'parts' => [[
|
84
|
+
"dVp1FjdfbtGF371TABXSeJ9HNPm9uBYQGaSyBasXqFmnGQqCiZEF0UWPTaG9\nwM7KV1GPwbj/GowwPT0Q8mv9wZ/bCQ2NlQ8Usuiol2SWtGtAYU74C6jzbQH6\ni1gq55I/T8JMiZmebnlnh/7rr9hOh9lQcjylbH792stsntxwlu4=\n",
|
85
|
+
"ZfP2yMLwNOe2yBU6UDrOjnE9OX0SX/xbfG+s4mjji6cvfmN7uuyoWTPa3tb8\n6/hNENIpRa/RPGTzeh/jeU7wYIiG3HGb6Z221S6ikEXYNtRqL0plOq8nY+kh\nxV+3PlBXhNNdUvtUTf3D5dtfWdxL2tuPJUnTnWyoNSDko+NXlHM=\n"
|
86
|
+
]],
|
87
|
+
'users' => [{
|
88
|
+
'id' => 1,
|
89
|
+
'username' => 'server',
|
90
|
+
'email' => 'server@localhost',
|
91
|
+
'public_key' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC8Z1K4aCksOb6rsbKNcF4fNcN\n1Tbyv+ids751YvmfU2WHDXB3wIVoN1YRdb8Dk8608YlGAAqVaGVwfgYdyLMppIGs\nglZIMjwZFM2F84T4swKOEJJx6o3ZCRnP9ZQcceqzcIuTjiIqC7xu+QOvtADAMW68\nzZIpFOHjjiuxkA7PQQIDAQAB\n-----END PUBLIC KEY-----\n",
|
92
|
+
'url' => 'https://example.com/users/1'
|
93
|
+
}, {
|
94
|
+
'id' => 2,
|
95
|
+
'username' => 'flower-pot',
|
96
|
+
'email' => 'flower-pot@example.org',
|
97
|
+
'public_key' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCftZvHkB6uKWVDvrIzmy2p496H\nv9PD/hhRk+DSXcE/CPtRmvYZzbWbbBup9hkvhyH/P1O5EF8KSZm4Cdnz6p37idTe\nNdlaH9cRFV2wc2A/hbg2kaISxrDxUqRbywBE9NOBSjXu2wRpy0TMo85eM2A0E2ET\n2XM6tZcuwFULX6bl8QIDAQAB\n-----END PUBLIC KEY-----\n",
|
98
|
+
'url' => 'https://example.com/users/2'
|
99
|
+
}],
|
100
|
+
'url' => 'http://example.com/secrets/1'
|
101
|
+
}.to_json
|
102
|
+
|
103
|
+
stub_request(:get, "https://example.com/secrets/1").
|
104
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
105
|
+
to_return(status: 200, body: payload)
|
106
|
+
end
|
107
|
+
|
108
|
+
def stub_secret_delete
|
109
|
+
stub_request(:delete, "https://example.com/secrets/1").
|
110
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
111
|
+
to_return(status: 204, body: "", headers: {})
|
112
|
+
end
|
113
|
+
|
114
|
+
def stub_create_secret
|
115
|
+
payload = {
|
116
|
+
'id' => 1,
|
117
|
+
'title' => 'test',
|
118
|
+
'users' => [{
|
119
|
+
'id' => 1,
|
120
|
+
'username' => 'server',
|
121
|
+
'email' => 'server@localhost',
|
122
|
+
'public_key' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC8Z1K4aCksOb6rsbKNcF4fNcN\n1Tbyv+ids751YvmfU2WHDXB3wIVoN1YRdb8Dk8608YlGAAqVaGVwfgYdyLMppIGs\nglZIMjwZFM2F84T4swKOEJJx6o3ZCRnP9ZQcceqzcIuTjiIqC7xu+QOvtADAMW68\nzZIpFOHjjiuxkA7PQQIDAQAB\n-----END PUBLIC KEY-----\n",
|
123
|
+
'url' => 'https://example.com/users/1'
|
124
|
+
}, {
|
125
|
+
'id' => 2,
|
126
|
+
'username' => 'flower-pot',
|
127
|
+
'email' => 'flower-pot@example.org',
|
128
|
+
'public_key' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCftZvHkB6uKWVDvrIzmy2p496H\nv9PD/hhRk+DSXcE/CPtRmvYZzbWbbBup9hkvhyH/P1O5EF8KSZm4Cdnz6p37idTe\nNdlaH9cRFV2wc2A/hbg2kaISxrDxUqRbywBE9NOBSjXu2wRpy0TMo85eM2A0E2ET\n2XM6tZcuwFULX6bl8QIDAQAB\n-----END PUBLIC KEY-----\n",
|
129
|
+
'url' => 'https://example.com/users/2'
|
130
|
+
}],
|
131
|
+
'parts' => [[
|
132
|
+
"dVp1FjdfbtGF371TABXSeJ9HNPm9uBYQGaSyBasXqFmnGQqCiZEF0UWPTaG9\nwM7KV1GPwbj/GowwPT0Q8mv9wZ/bCQ2NlQ8Usuiol2SWtGtAYU74C6jzbQH6\ni1gq55I/T8JMiZmebnlnh/7rr9hOh9lQcjylbH792stsntxwlu4=\n",
|
133
|
+
"ZfP2yMLwNOe2yBU6UDrOjnE9OX0SX/xbfG+s4mjji6cvfmN7uuyoWTPa3tb8\n6/hNENIpRa/RPGTzeh/jeU7wYIiG3HGb6Z221S6ikEXYNtRqL0plOq8nY+kh\nxV+3PlBXhNNdUvtUTf3D5dtfWdxL2tuPJUnTnWyoNSDko+NXlHM=\n"
|
134
|
+
]],
|
135
|
+
'url' => 'http://example.com/secrets/1'
|
136
|
+
}.to_json
|
137
|
+
stub_request(:post, "https://example.com/secrets").
|
138
|
+
with(headers: {'Accept'=>'application/vnd.duse.1+json'}).
|
139
|
+
to_return(status: 201, body: payload, headers: {})
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: duse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Frederic Branczyk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: highline
|
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: secret_sharing
|
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: faraday
|
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: faraday_middleware
|
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: CLI and Ruby client library for duse
|
70
|
+
email: fbranczyk@gmail.com
|
71
|
+
executables:
|
72
|
+
- duse
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/duse
|
84
|
+
- duse.gemspec
|
85
|
+
- lib/duse.rb
|
86
|
+
- lib/duse/cli.rb
|
87
|
+
- lib/duse/cli/account.rb
|
88
|
+
- lib/duse/cli/account_confirm.rb
|
89
|
+
- lib/duse/cli/account_info.rb
|
90
|
+
- lib/duse/cli/account_password.rb
|
91
|
+
- lib/duse/cli/account_password_change.rb
|
92
|
+
- lib/duse/cli/account_password_reset.rb
|
93
|
+
- lib/duse/cli/account_resend_confirmation.rb
|
94
|
+
- lib/duse/cli/account_update.rb
|
95
|
+
- lib/duse/cli/api_command.rb
|
96
|
+
- lib/duse/cli/cli_config.rb
|
97
|
+
- lib/duse/cli/command.rb
|
98
|
+
- lib/duse/cli/config.rb
|
99
|
+
- lib/duse/cli/help.rb
|
100
|
+
- lib/duse/cli/key_helper.rb
|
101
|
+
- lib/duse/cli/login.rb
|
102
|
+
- lib/duse/cli/meta_command.rb
|
103
|
+
- lib/duse/cli/parser.rb
|
104
|
+
- lib/duse/cli/password_helper.rb
|
105
|
+
- lib/duse/cli/register.rb
|
106
|
+
- lib/duse/cli/secret.rb
|
107
|
+
- lib/duse/cli/secret_add.rb
|
108
|
+
- lib/duse/cli/secret_generator.rb
|
109
|
+
- lib/duse/cli/secret_get.rb
|
110
|
+
- lib/duse/cli/secret_list.rb
|
111
|
+
- lib/duse/cli/secret_remove.rb
|
112
|
+
- lib/duse/cli/secret_update.rb
|
113
|
+
- lib/duse/cli/share_with_user.rb
|
114
|
+
- lib/duse/cli/version.rb
|
115
|
+
- lib/duse/client/config.rb
|
116
|
+
- lib/duse/client/entity.rb
|
117
|
+
- lib/duse/client/namespace.rb
|
118
|
+
- lib/duse/client/secret.rb
|
119
|
+
- lib/duse/client/session.rb
|
120
|
+
- lib/duse/client/user.rb
|
121
|
+
- lib/duse/encryption.rb
|
122
|
+
- lib/duse/version.rb
|
123
|
+
- spec/cli/cli_config_spec.rb
|
124
|
+
- spec/cli/commands/account_spec.rb
|
125
|
+
- spec/cli/commands/config_spec.rb
|
126
|
+
- spec/cli/commands/login_spec.rb
|
127
|
+
- spec/cli/commands/register_spec.rb
|
128
|
+
- spec/cli/commands/secret_spec.rb
|
129
|
+
- spec/client/secret_marshaller_spec.rb
|
130
|
+
- spec/client/secret_spec.rb
|
131
|
+
- spec/client/user_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- spec/support/helpers.rb
|
134
|
+
- spec/support/mock_api.rb
|
135
|
+
homepage: https://github.com/duse-io/duse.rb
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.4.5
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: Duse client
|
159
|
+
test_files: []
|