-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from tzumainn/console
Add console auth token resource
- Loading branch information
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from openstack import resource | ||
|
||
|
||
class ConsoleAuthToken(resource.Resource): | ||
resources_key = 'console_auth_tokens' | ||
base_path = '/console_auth_tokens' | ||
|
||
# capabilities | ||
allow_create = True | ||
allow_fetch = False | ||
allow_commit = True | ||
allow_delete = True | ||
allow_list = False | ||
commit_method = 'PATCH' | ||
commit_jsonpatch = True | ||
|
||
#: The transaction date and time. | ||
timestamp = resource.Header("x-timestamp") | ||
#: The value of the resource. Also available in headers. | ||
node_uuid = resource.Body("node_uuid", alternate_id=True) | ||
node_uuid_or_name = resource.Body("node_uuid_or_name") | ||
token = resource.Body("token") | ||
access_url = resource.Body("access_url") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from esi.lease.v1 import console_auth_token | ||
from openstack.tests.unit import base | ||
|
||
|
||
FAKE = {'node_uuid': 'node_001', | ||
'token': 'fake_token', | ||
'access_url': 'ws://0.0.0.0:7777?token=fake_token', | ||
} | ||
|
||
|
||
class TestConsoleAuthToken(base.TestCase): | ||
def test_basic(self): | ||
c = console_auth_token.ConsoleAuthToken() | ||
self.assertIsNone(c.resource_key) | ||
self.assertEqual('console_auth_tokens', c.resources_key) | ||
self.assertEqual('/console_auth_tokens', c.base_path) | ||
self.assertTrue(c.allow_create) | ||
self.assertFalse(c.allow_fetch) | ||
self.assertTrue(c.allow_commit) | ||
self.assertTrue(c.allow_delete) | ||
self.assertFalse(c.allow_list) | ||
self.assertEqual('PATCH', c.commit_method) | ||
|
||
def test_instantiate(self): | ||
c = console_auth_token.ConsoleAuthToken(**FAKE) | ||
self.assertEqual(FAKE['node_uuid'], c.node_uuid) | ||
self.assertEqual(FAKE['token'], c.token) | ||
self.assertEqual(FAKE['access_url'], c.access_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters