test/yao/test_token.rb in yao-0.2.11 vs test/yao/test_token.rb in yao-0.2.12

- old
+ new

@@ -9,19 +9,25 @@ def test_expired t = Yao::Token.new({}) t.register({ "id" => "aaaa166533fd49f3b11b1cdce2430000", "issued_at" => Time.now.iso8601, - "expires" => (Time.now - 3600).utc.iso8601 + "expires" => (Time.now - 3600).utc.iso8601, + "tenant" => { + "id" => "aaaa166533fd49f3b11b1cdce2430000" + } }) assert { t.expired? } t.register({ "id" => "aaaa166533fd49f3b11b1cdce2430000", "issued_at" => Time.now.iso8601, - "expires" => (Time.now + 3600).utc.iso8601 + "expires" => (Time.now + 3600).utc.iso8601, + "tenant" => { + "id" => "aaaa166533fd49f3b11b1cdce2430000" + } }) assert { ! t.expired? } end def test_reflesh @@ -40,17 +46,34 @@ } t = Yao::Token.new(auth_info) t.register({ "id" => "old_token", "issued_at" => Time.now.iso8601, - "expires" => (Time.now - 3600).utc.iso8601 + "expires" => (Time.now - 3600).utc.iso8601, + "tenant" => { + "id" => "aaaa166533fd49f3b11b1cdce2430000" + } }) assert { t.token == "old_token" } stub_auth_request(auth_url, username, password, tenant) Yao.config.auth_url auth_url t.reflesh(Yao.default_client.default) assert { t.token == "aaaa166533fd49f3b11b1cdce2430000" } + end + + def test_current_tenant_id + t = Yao::Token.new({}) + t.register({ + "id" => "aaaa166533fd49f3b11b1cdce2430000", + "issued_at" => Time.now.iso8601, + "expires" => (Time.now - 3600).utc.iso8601, + "tenant" => { + "id" => "aaaa166533fd49f3b11b1cdce2430000" + } + }) + + assert { Yao.current_tenant_id == "aaaa166533fd49f3b11b1cdce2430000" } end end