yao 0.2.11 → 0.2.12
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 +4 -4
- data/.gitignore +3 -1
- data/lib/yao/auth.rb +0 -1
- data/lib/yao/client.rb +0 -1
- data/lib/yao/config.rb +1 -3
- data/lib/yao/token.rb +8 -1
- data/lib/yao/version.rb +1 -1
- data/test/yao/resources/test_role.rb +12 -0
- data/test/yao/resources/test_security_group.rb +25 -0
- data/test/yao/resources/test_security_group_rule.rb +23 -0
- data/test/yao/resources/test_user.rb +13 -0
- data/test/yao/test_token.rb +26 -3
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 906c17b5fd4d30db28ae3338f591a18cff3798e2
|
4
|
+
data.tar.gz: f9f55488c58e43f8ac6c50923cc717ce4091bb11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f935edeb5201604969ad2ac71ad39b25795d55f02e9d7fdc4ad8bd7048b1eca1ee15289bae1cb3a6e4717368a7a7fc01d6bfd0f4c24a7065eb55927f320836f9
|
7
|
+
data.tar.gz: c45079ed8e8e107660d19c683155d43bce62e4ee3504c8885ed7b72d0c43f60bfb1a601282405f3640288ed4dbfcf00254f7d52750449646a574f338c6b981be
|
data/.gitignore
CHANGED
data/lib/yao/auth.rb
CHANGED
data/lib/yao/client.rb
CHANGED
data/lib/yao/config.rb
CHANGED
data/lib/yao/token.rb
CHANGED
@@ -21,6 +21,7 @@ module Yao
|
|
21
21
|
@token = token_data["id"]
|
22
22
|
@issued_at = Time.parse(token_data["issued_at"]).localtime
|
23
23
|
@expire_at = Time.parse(token_data["expires"]).localtime
|
24
|
+
Yao.current_tenant_id token_data["tenant"]["id"]
|
24
25
|
end
|
25
26
|
|
26
27
|
def expired?
|
@@ -35,7 +36,6 @@ module Yao
|
|
35
36
|
req.body = auth_info.to_json
|
36
37
|
req.headers['Content-Type'] = 'application/json'
|
37
38
|
end
|
38
|
-
|
39
39
|
body = res.body["access"]
|
40
40
|
|
41
41
|
register(body["token"])
|
@@ -59,4 +59,11 @@ module Yao
|
|
59
59
|
Yao.default_client.register_endpoints(@endpoints, token: self)
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
def self.current_tenant_id(id=nil)
|
64
|
+
if id
|
65
|
+
@__tenant_id = id
|
66
|
+
end
|
67
|
+
@__tenant_id
|
68
|
+
end
|
62
69
|
end
|
data/lib/yao/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
class TestRole < Test::Unit::TestCase
|
2
|
+
def test_role_attributes
|
3
|
+
params = {
|
4
|
+
"name" => "test_role",
|
5
|
+
"description" => "test_description_1"
|
6
|
+
}
|
7
|
+
|
8
|
+
role = Yao::Role.new(params)
|
9
|
+
assert_equal(role.name, "test_role")
|
10
|
+
assert_equal(role.description, "test_description_1")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class TestSecurityGroup < Test::Unit::TestCase
|
2
|
+
def test_sg_attributes
|
3
|
+
params = {
|
4
|
+
"id" => "test_group_id_1",
|
5
|
+
"name" => "test_group_name_1",
|
6
|
+
"description" => "test_description_1",
|
7
|
+
"security_group_rules" => [
|
8
|
+
{
|
9
|
+
"id" => "test_rule_id_1",
|
10
|
+
"direction" => "ingress",
|
11
|
+
"protocol" => "tcp",
|
12
|
+
"ethertype" => "IPv4",
|
13
|
+
"port" => "443",
|
14
|
+
"remote_ip" => "10.0.0.0/24"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
|
19
|
+
sg = Yao::SecurityGroup.new(params)
|
20
|
+
assert_equal(sg.name, "test_group_name_1")
|
21
|
+
assert_equal(sg.id, "test_group_id_1")
|
22
|
+
assert_equal(sg.description, "test_description_1")
|
23
|
+
assert(sg.rules[0].instance_of?(Yao::SecurityGroupRule))
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class TestSecurityGroup < Test::Unit::TestCase
|
2
|
+
def test_rule_attributes
|
3
|
+
params = {
|
4
|
+
"id" => "test_rule_id_1",
|
5
|
+
"security_group_ip" => "test_group_id_1",
|
6
|
+
"direction" => "ingress",
|
7
|
+
"protocol" => "tcp",
|
8
|
+
"ethertype" => "IPv4",
|
9
|
+
"port_range_max" => "443",
|
10
|
+
"port_range_min" => "443",
|
11
|
+
"remote_ip_prefix" => "10.0.0.0/24",
|
12
|
+
"remote_group_id" => nil,
|
13
|
+
"tenant_id" => "test_tenant"
|
14
|
+
}
|
15
|
+
|
16
|
+
rule = Yao::SecurityGroupRule.new(params)
|
17
|
+
assert_equal(rule.id, "test_rule_id_1")
|
18
|
+
assert_equal(rule.protocol, "tcp")
|
19
|
+
assert_equal(rule.port_range_max, "443")
|
20
|
+
assert_equal(rule.port_range_min, "443")
|
21
|
+
assert_equal(rule.ethertype, "IPv4")
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class TestUser < Test::Unit::TestCase
|
2
|
+
def test_sg_attributes
|
3
|
+
params = {
|
4
|
+
"name" => "test_user",
|
5
|
+
"email" => "test-user@example.com",
|
6
|
+
"password" => "passw0rd"
|
7
|
+
}
|
8
|
+
|
9
|
+
user = Yao::User.new(params)
|
10
|
+
assert_equal(user.name, "test_user")
|
11
|
+
assert_equal(user.email, "test-user@example.com")
|
12
|
+
end
|
13
|
+
end
|
data/test/yao/test_token.rb
CHANGED
@@ -11,7 +11,10 @@ class TestToken < Test::Unit::TestCase
|
|
11
11
|
t.register({
|
12
12
|
"id" => "aaaa166533fd49f3b11b1cdce2430000",
|
13
13
|
"issued_at" => Time.now.iso8601,
|
14
|
-
"expires" => (Time.now - 3600).utc.iso8601
|
14
|
+
"expires" => (Time.now - 3600).utc.iso8601,
|
15
|
+
"tenant" => {
|
16
|
+
"id" => "aaaa166533fd49f3b11b1cdce2430000"
|
17
|
+
}
|
15
18
|
})
|
16
19
|
|
17
20
|
assert { t.expired? }
|
@@ -19,7 +22,10 @@ class TestToken < Test::Unit::TestCase
|
|
19
22
|
t.register({
|
20
23
|
"id" => "aaaa166533fd49f3b11b1cdce2430000",
|
21
24
|
"issued_at" => Time.now.iso8601,
|
22
|
-
"expires" => (Time.now + 3600).utc.iso8601
|
25
|
+
"expires" => (Time.now + 3600).utc.iso8601,
|
26
|
+
"tenant" => {
|
27
|
+
"id" => "aaaa166533fd49f3b11b1cdce2430000"
|
28
|
+
}
|
23
29
|
})
|
24
30
|
assert { ! t.expired? }
|
25
31
|
end
|
@@ -42,7 +48,10 @@ class TestToken < Test::Unit::TestCase
|
|
42
48
|
t.register({
|
43
49
|
"id" => "old_token",
|
44
50
|
"issued_at" => Time.now.iso8601,
|
45
|
-
"expires" => (Time.now - 3600).utc.iso8601
|
51
|
+
"expires" => (Time.now - 3600).utc.iso8601,
|
52
|
+
"tenant" => {
|
53
|
+
"id" => "aaaa166533fd49f3b11b1cdce2430000"
|
54
|
+
}
|
46
55
|
})
|
47
56
|
assert { t.token == "old_token" }
|
48
57
|
|
@@ -53,4 +62,18 @@ class TestToken < Test::Unit::TestCase
|
|
53
62
|
|
54
63
|
assert { t.token == "aaaa166533fd49f3b11b1cdce2430000" }
|
55
64
|
end
|
65
|
+
|
66
|
+
def test_current_tenant_id
|
67
|
+
t = Yao::Token.new({})
|
68
|
+
t.register({
|
69
|
+
"id" => "aaaa166533fd49f3b11b1cdce2430000",
|
70
|
+
"issued_at" => Time.now.iso8601,
|
71
|
+
"expires" => (Time.now - 3600).utc.iso8601,
|
72
|
+
"tenant" => {
|
73
|
+
"id" => "aaaa166533fd49f3b11b1cdce2430000"
|
74
|
+
}
|
75
|
+
})
|
76
|
+
|
77
|
+
assert { Yao.current_tenant_id == "aaaa166533fd49f3b11b1cdce2430000" }
|
78
|
+
end
|
56
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uchio, KONDO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -204,6 +204,10 @@ files:
|
|
204
204
|
- lib/yao/version.rb
|
205
205
|
- test/config.rb
|
206
206
|
- test/support/auth_stub.rb
|
207
|
+
- test/yao/resources/test_role.rb
|
208
|
+
- test/yao/resources/test_security_group.rb
|
209
|
+
- test/yao/resources/test_security_group_rule.rb
|
210
|
+
- test/yao/resources/test_user.rb
|
207
211
|
- test/yao/test_auth.rb
|
208
212
|
- test/yao/test_client.rb
|
209
213
|
- test/yao/test_client_plugin.rb
|
@@ -233,13 +237,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
237
|
version: '0'
|
234
238
|
requirements: []
|
235
239
|
rubyforge_project:
|
236
|
-
rubygems_version: 2.4.
|
240
|
+
rubygems_version: 2.4.8
|
237
241
|
signing_key:
|
238
242
|
specification_version: 4
|
239
243
|
summary: Yet Another OpenStack API Wrapper that rocks!!
|
240
244
|
test_files:
|
241
245
|
- test/config.rb
|
242
246
|
- test/support/auth_stub.rb
|
247
|
+
- test/yao/resources/test_role.rb
|
248
|
+
- test/yao/resources/test_security_group.rb
|
249
|
+
- test/yao/resources/test_security_group_rule.rb
|
250
|
+
- test/yao/resources/test_user.rb
|
243
251
|
- test/yao/test_auth.rb
|
244
252
|
- test/yao/test_client.rb
|
245
253
|
- test/yao/test_client_plugin.rb
|