~ubuntu-branches/ubuntu/raring/glance/raring-updates

« back to all changes in this revision

Viewing changes to glance/tests/unit/test_auth.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandleman, Chuck Short
  • Date: 2012-08-16 13:58:32 UTC
  • mfrom: (1.1.41)
  • Revision ID: package-import@ubuntu.com-20120816135832-4m40ppptd1l073fr
Tags: 2012.2~f3-0ubuntu1
[ Adam Gandleman ]
* debian/patches/sql_conn.patch: Also set default sqlite path for
  in glance-api.conf. (LP: #1028711)
* debian/patches/fix-docs-build.patch: Fix docs build

[ Chuck Short ]
* New upstream version.
* debian/control: python-xattr is no longer a required depends.
  (LP: #1031396)
* debian/control: Move python-jsonschema to glance.
  (LP: #1030152)
* debian/control: Start the slow transition to python-glanceclient.

Show diffs side-by-side

added added

removed removed

Lines of Context:
492
492
                      "type encountered")
493
493
        except exception.NoServiceEndpoint:
494
494
            pass
 
495
 
 
496
 
 
497
class TestEndpoints(utils.BaseTestCase):
 
498
 
 
499
    def setUp(self):
 
500
        self.service_catalog = [
 
501
            {'endpoint_links': [],
 
502
             'endpoints': [
 
503
                 {'adminURL': 'http://localhost:8080/',
 
504
                 'region': 'RegionOne',
 
505
                 'internalURL': 'http://internalURL/',
 
506
                 'publicURL': 'http://publicURL/'},
 
507
             ],
 
508
             'type': 'object-store',
 
509
             'name': 'Object Storage Service',
 
510
            }]
 
511
 
 
512
    def test_get_endpoint_with_custom_server_type(self):
 
513
        endpoint = auth.get_endpoint(self.service_catalog,
 
514
                                     service_type='object-store')
 
515
        self.assertEquals('http://publicURL/', endpoint)
 
516
 
 
517
    def test_get_endpoint_with_custom_endpoint_type(self):
 
518
        endpoint = auth.get_endpoint(self.service_catalog,
 
519
                                     service_type='object-store',
 
520
                                     endpoint_type='internalURL')
 
521
        self.assertEquals('http://internalURL/', endpoint)
 
522
 
 
523
    def test_get_endpoint_raises_with_invalid_service_type(self):
 
524
        self.assertRaises(exception.NoServiceEndpoint,
 
525
                          auth.get_endpoint,
 
526
                          self.service_catalog,
 
527
                          service_type='foo')
 
528
 
 
529
    def test_get_endpoint_raises_with_invalid_endpoint_type(self):
 
530
        self.assertRaises(exception.NoServiceEndpoint,
 
531
                          auth.get_endpoint,
 
532
                          self.service_catalog,
 
533
                          service_type='object-store',
 
534
                          endpoint_type='foo')
 
535
 
 
536
    def test_get_endpoint_raises_with_invalid_endpoint_region(self):
 
537
        self.assertRaises(exception.NoServiceEndpoint,
 
538
                          auth.get_endpoint,
 
539
                          self.service_catalog,
 
540
                          service_type='object-store',
 
541
                          endpoint_region='foo',
 
542
                          endpoint_type='internalURL')