Ejemplo n.º 1
0
    def test_catalog_can_return_multiple_services(self):
        self.broker.catalog.return_value = [
            Service(id='s1',
                    name='service_name1',
                    description='service_description1',
                    bindable=True,
                    plans=[
                        ServicePlan(id='p1',
                                    name='default1',
                                    description='plan_description1')
                    ]),
            Service(id='s2',
                    name='service_name2',
                    description='service_description2',
                    bindable=True,
                    plans=[
                        ServicePlan(id='p2',
                                    name='default2',
                                    description='plan_description2')
                    ])
        ]

        response = self.client.get('/v2/catalog',
                                   headers={
                                       'X-Broker-Api-Version': '2.13',
                                       'Authorization': self.auth_header,
                                       'unknown': 'unknown'
                                   })

        self.assertEqual(response.status_code, http.HTTPStatus.OK)
        self.assertDictEqual(
            dict(services=[
                dict(id='s1',
                     name='service_name1',
                     description='service_description1',
                     bindable=True,
                     instances_retrievable=False,
                     bindings_retrievable=False,
                     plan_updateable=False,
                     plans=[
                         dict(id='p1',
                              name='default1',
                              description='plan_description1')
                     ]),
                dict(id='s2',
                     name='service_name2',
                     description='service_description2',
                     bindable=True,
                     instances_retrievable=False,
                     bindings_retrievable=False,
                     plan_updateable=False,
                     plans=[
                         dict(id='p2',
                              name='default2',
                              description='plan_description2')
                     ])
            ]), response.json)
Ejemplo n.º 2
0
    def setUp(self) -> None:
        self.b1 = Mock()
        self.s1 = Service(id='s1', name='s1', description='s1', bindable=True,
                          plans=[ServicePlan('p1', name='', description='')])
        self.b1.catalog.return_value = [self.s1]

        self.b2 = Mock()
        self.s2 = Service(id='s2', name='s2', description='s2', bindable=True,
                          plans=[ServicePlan('p2', name='', description='')])
        self.b2.catalog.return_value = [self.s2]

        self.router = Router(self.b1, self.b2)
 def plans(self) -> List[ServicePlan]:
     plans = [
         ServicePlan(
             id='hello-mongodb-ops-manager',
             name='hello-mongodb-ops-manager',
             description=
             'Installs a demonstration version of MongoDB Ops Manager.',
         ),
         ServicePlan(
             id='hello-mongodb-kubernetes-operator',
             name='hello-mongodb-kubernetes-operator',
             description=
             'Installs a demonstration version of the MongoDB Kubernetes Operator',
         )
     ]
     self.myplans = plans[:]
     return plans
Ejemplo n.º 4
0
 def setUp(self):
     self.broker.catalog.return_value = [
         Service(
             id='service-guid-here',
             name='',
             description='',
             bindable=True,
             plans=[ServicePlan('plan-guid-here', name='', description='')])
     ]
Ejemplo n.º 5
0
 def catalog(self) -> Service:
     return Service(id=self.service_guid,
                    name='TestService',
                    description='TestMe',
                    bindable=False,
                    plans=[
                        ServicePlan(id=self.plan_guid,
                                    name='TestPlan',
                                    description='TestMe')
                    ])
Ejemplo n.º 6
0
 def plans(self) -> List[ServicePlan]:
   plans=[
     ServicePlan(
         id='standard-mongodb-replset',
         name='standard-mongodb-replset',
         description='Standard MongoDB replica set. Allows configuration.',
     )
   ]
   self.myplans = plans[:]
   return plans
Ejemplo n.º 7
0
    def __init__(self, atlas_credentials, mongo_credentials, clusters=None):
        self.atlas = atlas_credentials
        self.mongo = mongo_credentials

        # Broker Service configuration
        self.broker = {
            "id":
            self.UUID_SERVICES_CLUSTER,
            "name":
            "atlas-mongodb-cluster",
            "description":
            "Atlas/MongoDB for applications",
            "bindable":
            True,
            "plans": [
                ServicePlan(
                    id=self.UUID_PLANS_EXISTING_CLUSTER,
                    name="atlas-mongodb-existing-cluster",
                    description="Atlas/MongoDB: Configure an existing cluster",
                    metadata=None,
                    free=False,
                    bindable=True),
            ],
            "tags": ['atlas', 'mongodb'],
            "requires":
            None,
            "metadata":
            ServiceMetadata(
                displayName='Atlas - MongoDB Cloud Provider',
                imageUrl=None,
                longDescription=None,
                providerDisplayName=None,
                documentationUrl=None,
                supportUrl=None,
            ),
            "dashboard_client":
            None,
            "plan_updateable":
            False,
        }

        # Clusters configuration
        if clusters:
            self.clusters = clusters
        else:
            # load from Atlas
            atlas = Atlas(self.atlas["user"], self.atlas["password"],
                          self.atlas["group"])
            self.clusters = {}
            for cluster in atlas.Clusters.get_all_clusters(iterable=True):
                uri = cluster["mongoURIWithOptions"].replace(
                    'mongodb://', 'mongodb://%s:%s@').replace('/?', '/%s?')
                self.clusters[cluster["name"]] = uri
Ejemplo n.º 8
0
 def catalog(self) -> Union[Service, List[Service]]:
     return Service(id='service id 2',
                    name='service name 2',
                    description='service description 2',
                    bindable=False,
                    plans=[
                        ServicePlan(
                            id='plan id',
                            name='plan name',
                            description='plan description',
                        )
                    ])
Ejemplo n.º 9
0
 def catalog(self) -> Service:
     return Service(id=self.service_guid,
                    name='Jenkins enabled Git',
                    description='Create jenkins job for a given git repo',
                    bindable=True,
                    bindings_retrievable=True,
                    instances_retrievable=True,
                    plans=[
                        ServicePlan(id=self.plan_guid,
                                    name='Testing Plan',
                                    description='Used in Testing process',
                                    free=True)
                    ])
 def catalog(self) -> Union[Service, List[Service]]:
     return Service(id=self.service_guid,
                    name='InMemService',
                    description='InMemService',
                    bindable=True,
                    plans=[
                        ServicePlan(
                            id=self.plan_guid,
                            name='standard',
                            description='standard plan',
                            free=False,
                        )
                    ],
                    instances_retrievable=False,
                    bindings_retrievable=False)
    def __load_plans(self) -> List[ServicePlan]:
        plans = []
        #if not os.path.exists(plan_file):
        #self.logger.warn(f'No "plan.yaml" found in {self.plans_dir}, unable to load additional plan information. This may be just fine, maybe this plan does not need one. Consider adding an empty .plan.yaml.ignore file in the repoted path to suppress this warning.')
        #  self.logger.warn(f'No "plan.yaml" found in {self.plans_dir}.')
        #plan_info = yaml.load(plan_file)

        plan_ids = self.__plan_ids
        for plan_id in plan_ids:
            this_plan_dir = os.path.join(self.plans_dir, plan_id)
            #plan_file = os.path.join( this_plan_dir, 'plan.yaml' )
            #ignore_plan_file = os.path.join( self.plans_dir, '.plan.yaml.ignore')
            #if not os.path.exists( ignore_plan_file ):
            #  plan = plan_from_plan_file(plan_file)
            #else:
            desc = f'Plan id:{plan_id} plan_dir:{this_plan_dir}'
            plan = ServicePlan(id=plan_id, name=plan_id, description=desc)
            #
            plans.append(plan)
        self.logger.debug(f'__load_plans {plans}')
        return plans
Ejemplo n.º 12
0
 def catalog(self):
     return Service(
         id='c4573c4b-0fec-4c2d-b650-a3daa91a3bf0',
         name='tu-cloud',
         description=
         'File Sync and Share service located on servers of the TU Wien.',
         bindable=True,
         metadata=ServiceMetadata(
             displayName='TUcloud',
             imageUrl='http://example.com/tucloud_logo.png',
             longDescription=
             'With our File Sync and Share service, you can save your data to a \"virtual memory stick\". The open source software ownCloud runs on TU.it servers and basically offers the familiar features also provided by public cloud systems such as Dropbox.',
             providerDisplayName='TU.it',
             documentationUrl='https://www.it.tuwien.ac.at/tuprocloud/',
             supportUrl='https://support.tuwien.ac.at/assystnet/'),
         plans=[
             ServicePlan(
                 id='b1e8a5fd-0abc-4259-8d66-ab6fe8ee8b1d',
                 name='tu-owncloud',
                 description=
                 'Free file sync and share service for internal use.',
                 free=True,
                 metadata=ServicePlanMetaData(
                     displayName='TUownCloud',
                     bullets=[
                         '20 GB of personal storage space',
                         'Running on TU.it servers - your data is present locally on our systems',
                         'Data access possible via clients, web and WebDAV',
                         'Synchronisation with any number of devices is either automatic or in accordance with settings you make yourself'
                     ])),
             ServicePlan(
                 id='433b4d74-6ed9-41f5-81e6-4bef7fd66c1f',
                 name='tu-procloud',
                 description=
                 'File sync and share service for collaboration with external project partners.',
                 free=False,
                 metadata=ServicePlanMetaData(
                     displayName='TUproCloud',
                     bullets=[
                         'Collaborate with external project partners',
                         'File-synchronization and sharing',
                         'Configure access / authorization of members',
                         'Several 100GB of storage possible'
                     ],
                     costs=[
                         ServicePlanCost(amount={'eur': 0.03},
                                         unit='GB per quarter')
                     ]),
                 schemas=Schemas(
                     service_instance={
                         'create': {
                             'parameters': {
                                 '$schema':
                                 'http://json-schema.org/draft-04/schema#',
                                 'type': 'object',
                                 'properties': {
                                     'name': {
                                         'description':
                                         'Unique TU-wide name, not changeable.',
                                         'type': 'string'
                                     },
                                     'size': {
                                         'description':
                                         'Size of storage in GB.',
                                         'type': 'int'
                                     },
                                 }
                             }
                         },
                         'update': {
                             'parameters': {
                                 '$schema':
                                 'http://json-schema.org/draft-04/schema#',
                                 'type': 'object',
                                 'properties': {
                                     'size': {
                                         'description':
                                         'Size of storage in GB.',
                                         'type': 'int'
                                     },
                                 }
                             }
                         }
                     },
                     service_binding={
                         'create': {
                             'parameters': {
                                 '$schema':
                                 'http://json-schema.org/draft-04/schema#',
                                 'type': 'object',
                                 'properties': {
                                     'xxxx': {
                                         'description':
                                         'Some parameter needed for binding the service instance.',
                                         'type': 'string'
                                     }
                                 }
                             }
                         }
                     }))
         ],
         tags=['cloud-storage', 'file-sync', 'share'],
         plan_updateable=True,
     )
Ejemplo n.º 13
0
 def catalog(self):
     return Service(
         id='f02f46b2-d20d-4b6b-a9fa-6e7d28fddc9c',
         name='tu-files',
         description=
         'Highly available network drive for institutes and organizational units.',
         bindable=True,
         metadata=ServiceMetadata(
             displayName='TUfiles',
             imageUrl='http://example.com/tufiles_logo.png',
             longDescription=
             'With TUfiles, we give you the opportunity to store data on a central and readily available network drive with backup (hosted on Windows servers). TUfiles is suitable for storing data with moderate access requirements, but high availability demands. TUfiles is not suitable for applications demanding high storage performance for a long period of time, such as high-performance databases, computer applications with high data access requirements and for storing local Microsoft Outlook PST files and backups.',
             providerDisplayName='TU.it',
             documentationUrl='https://www.it.tuwien.ac.at/tufiles/',
             supportUrl='https://support.tuwien.ac.at/assystnet/'),
         plans=[
             ServicePlan(
                 id='04cd4e4a-f296-4090-b4f4-0e5717bb90c6',
                 name='standard',
                 description=
                 'Highly available network drive with standard authorization concept.',
                 free=False,
                 metadata=ServicePlanMetaData(
                     displayName='Standard authorization concept',
                     bullets=[
                         'Redundant and readily available network drive',
                         'You can personally administer access rights and authorisations in folders',
                         'Useful for working with older file versions',
                         'With Windows 7/8/8.1/10, Linux and MacOS from SMB version 2.1',
                         'Not intended for storing your backups'
                     ],
                     costs=[
                         ServicePlanCost(amount={'eur': 0.03},
                                         unit='GB per quarter')
                     ]),
                 schemas=Schemas(
                     service_instance={
                         'create': {
                             'parameters': {
                                 '$schema':
                                 'http://json-schema.org/draft-04/schema#',
                                 'type': 'object',
                                 'properties': {
                                     'share-name': {
                                         'description':
                                         'Name of the network drive.',
                                         'type': 'string'
                                     },
                                     'size': {
                                         'description':
                                         'Size of storage in GB.',
                                         'type': 'int'
                                     },
                                     'authorization-group': {
                                         'description':
                                         'Name of the upTUdate authorization group.',
                                         'type': 'string'
                                     }
                                 }
                             }
                         },
                         'update': {
                             'parameters': {
                                 '$schema':
                                 'http://json-schema.org/draft-04/schema#',
                                 'type': 'object',
                                 'properties': {
                                     'size': {
                                         'description':
                                         'Size of storage in GB.',
                                         'type': 'int'
                                     },
                                 }
                             }
                         }
                     },
                     service_binding={
                         'create': {
                             'parameters': {
                                 '$schema':
                                 'http://json-schema.org/draft-04/schema#',
                                 'type': 'object',
                                 'properties': {
                                     'xxxx': {
                                         'description':
                                         'Some parameter needed for binding the service instance.',
                                         'type': 'string'
                                     }
                                 }
                             }
                         }
                     }))
         ],
         tags=['network-drive', 'storage'],
         plan_updateable=True,
     )
Ejemplo n.º 14
0
class CatalogTest(BrokerTestCase):
    service = Service(id="s1",
                      name="service_name",
                      description="service_description",
                      bindable=True,
                      plans=[
                          ServicePlan(id="p1",
                                      name="default",
                                      description="plan_description")
                      ])

    def test_catalog_called_with_the_right_values(self):
        self.broker.catalog.return_value = self.service

        self.client.get("/v2/catalog",
                        headers={
                            'X-Broker-Api-Version': '2.13',
                            'Authorization': self.auth_header
                        })

        self.assertTrue(self.broker.catalog.called)

    def test_catalog_ignores_request_headers(self):
        self.broker.catalog.return_value = self.service

        self.client.get("/v2/catalog",
                        headers={
                            'X-Broker-Api-Version': '2.13',
                            'Authorization': self.auth_header,
                            "unknown": "unknown"
                        })

        self.assertTrue(self.broker.catalog.called)

    def test_catalog_returns_200_with_service_information(self):
        self.broker.catalog.return_value = Service(
            id="s1",
            name="service_name",
            description="service_description",
            bindable=True,
            plans=[
                ServicePlan(id="p1",
                            name="default",
                            description="plan_description",
                            metadata=ServicePlanMetaData(
                                displayName="displayName",
                                bullets=["bullet1"],
                                costs=[
                                    ServicePlanCost(amount={"requests": 1},
                                                    unit="unit")
                                ]),
                            free=True,
                            bindable=True)
            ],
            tags=['tag1', 'tag2'],
            requires=['something'],
            metadata=ServiceMetadata(displayName="displayName",
                                     imageUrl="imageUrl",
                                     longDescription="longDescription",
                                     providerDisplayName="providerDisplayName",
                                     documentationUrl="documentationUrl",
                                     supportUrl="supportUrl"),
            dashboard_client=ServiceDashboardClient(
                id="id", secret="secret", redirect_uri="redirect_uri"),
            plan_updateable=True)

        response = self.client.get("/v2/catalog",
                                   headers={
                                       'X-Broker-Api-Version': '2.13',
                                       'Authorization': self.auth_header,
                                       "unknown": "unknown"
                                   })

        self.assertEqual(response.status_code, http.HTTPStatus.OK)
        self.assertEqual(
            response.json,
            dict(services=[
                dict(id="s1",
                     name="service_name",
                     description="service_description",
                     bindable=True,
                     plans=[
                         dict(id="p1",
                              name="default",
                              description="plan_description",
                              metadata=dict(displayName="displayName",
                                            bullets=["bullet1"],
                                            costs=[
                                                dict(amount={"requests": 1},
                                                     unit="unit")
                                            ]),
                              free=True,
                              bindable=True)
                     ],
                     tags=['tag1', 'tag2'],
                     requires=['something'],
                     metadata=dict(displayName="displayName",
                                   imageUrl="imageUrl",
                                   longDescription="longDescription",
                                   providerDisplayName="providerDisplayName",
                                   documentationUrl="documentationUrl",
                                   supportUrl="supportUrl"),
                     dashboard_client=dict(id="id",
                                           secret="secret",
                                           redirect_uri="redirect_uri"),
                     plan_updateable=True)
            ]))

    def test_catalog_returns_200_with_minimal_service_information(self):
        self.broker.catalog.return_value = self.service

        response = self.client.get(
            "/v2/catalog",
            headers={
                'X-Broker-Api-Version':
                '2.13',
                'X-Broker-Api-Originating-Identity':
                'test ' +
                base64.standard_b64encode(b'{"user_id":123}').decode('ascii'),
                'Authorization':
                self.auth_header,
                "unknown":
                "unknown"
            })

        self.assertEqual(response.status_code, http.HTTPStatus.OK)
        self.assertEqual(
            response.json,
            dict(services=[
                dict(id="s1",
                     name="service_name",
                     description="service_description",
                     bindable=True,
                     plan_updateable=False,
                     plans=[
                         dict(id="p1",
                              name="default",
                              description="plan_description")
                     ])
            ]))

    def test_catalog_returns_500_if_error_raised(self):
        self.broker.catalog.side_effect = Exception("ERROR")

        response = self.client.get("/v2/catalog",
                                   headers={
                                       'X-Broker-Api-Version': '2.13',
                                       'Authorization': self.auth_header,
                                       "unknown": "unknown"
                                   })

        self.assertEqual(response.status_code,
                         http.HTTPStatus.INTERNAL_SERVER_ERROR)
        self.assertEqual(response.json, dict(description="ERROR"))
Ejemplo n.º 15
0
    def test_catalog_returns_200_with_service_information(self):
        self.broker.catalog.return_value = Service(
            id="s1",
            name="service_name",
            description="service_description",
            bindable=True,
            plans=[
                ServicePlan(id="p1",
                            name="default",
                            description="plan_description",
                            metadata=ServicePlanMetaData(
                                displayName="displayName",
                                bullets=["bullet1"],
                                costs=[
                                    ServicePlanCost(amount={"requests": 1},
                                                    unit="unit")
                                ]),
                            free=True,
                            bindable=True)
            ],
            tags=['tag1', 'tag2'],
            requires=['something'],
            metadata=ServiceMetadata(displayName="displayName",
                                     imageUrl="imageUrl",
                                     longDescription="longDescription",
                                     providerDisplayName="providerDisplayName",
                                     documentationUrl="documentationUrl",
                                     supportUrl="supportUrl"),
            dashboard_client=ServiceDashboardClient(
                id="id", secret="secret", redirect_uri="redirect_uri"),
            plan_updateable=True)

        response = self.client.get("/v2/catalog",
                                   headers={
                                       'X-Broker-Api-Version': '2.13',
                                       'Authorization': self.auth_header,
                                       "unknown": "unknown"
                                   })

        self.assertEqual(response.status_code, http.HTTPStatus.OK)
        self.assertEqual(
            response.json,
            dict(services=[
                dict(id="s1",
                     name="service_name",
                     description="service_description",
                     bindable=True,
                     plans=[
                         dict(id="p1",
                              name="default",
                              description="plan_description",
                              metadata=dict(displayName="displayName",
                                            bullets=["bullet1"],
                                            costs=[
                                                dict(amount={"requests": 1},
                                                     unit="unit")
                                            ]),
                              free=True,
                              bindable=True)
                     ],
                     tags=['tag1', 'tag2'],
                     requires=['something'],
                     metadata=dict(displayName="displayName",
                                   imageUrl="imageUrl",
                                   longDescription="longDescription",
                                   providerDisplayName="providerDisplayName",
                                   documentationUrl="documentationUrl",
                                   supportUrl="supportUrl"),
                     dashboard_client=dict(id="id",
                                           secret="secret",
                                           redirect_uri="redirect_uri"),
                     plan_updateable=True)
            ]))
Ejemplo n.º 16
0
class CatalogTest(BrokerTestCase):
    service = Service(
        id='s1',
        name='service_name',
        description='service_description',
        bindable=True,
        plans=[ServicePlan(id='p1', name='default', description='plan_description')]
    )

    def test_catalog_called_with_the_right_values(self):
        self.broker.catalog.return_value = self.service

        self.client.get(
            '/v2/catalog',
            headers={
                'X-Broker-Api-Version': '2.13',
                'Authorization': self.auth_header
            })

        self.assertTrue(self.broker.catalog.called)

    def test_catalog_ignores_request_headers(self):
        self.broker.catalog.return_value = self.service

        self.client.get(
            '/v2/catalog',
            headers={
                'X-Broker-Api-Version': '2.13',
                'Authorization': self.auth_header,
                'unknown': 'unknown'
            })

        self.assertTrue(self.broker.catalog.called)

    def test_catalog_returns_200_with_service_information(self):
        '''
        This tests all the possible information a catalog could have. Including custom Service-/ServicePlanMetadata
        '''
        self.broker.catalog.return_value = Service(
            id='s1',
            name='service_name',
            description='service_description',
            bindable=True,
            plans=[ServicePlan(
                id='p1',
                name='default',
                description='plan_description',
                metadata=ServicePlanMetadata(
                    displayName='displayName',
                    bullets=['bullet1'],
                    costs=[ServicePlanCost(
                        amount={'requests': 1},
                        unit='unit'
                    )],
                    custom_field2='custom_field2'
                ),
                free=True,
                bindable=True
            )],
            tags=['tag1', 'tag2'],
            requires=['something'],
            metadata=ServiceMetadata(
                displayName='displayName',
                imageUrl='imageUrl',
                longDescription='longDescription',
                providerDisplayName='providerDisplayName',
                documentationUrl='documentationUrl',
                supportUrl='supportUrl',
                shareable=True,
                custom_field1='custom_field1'
            ),
            dashboard_client=ServiceDashboardClient(
                id='id',
                secret='secret',
                redirect_uri='redirect_uri'
            ),
            plan_updateable=True
        )

        response = self.client.get(
            '/v2/catalog',
            headers={
                'X-Broker-Api-Version': '2.13',
                'Authorization': self.auth_header,
                'unknown': 'unknown'
            })

        self.assertEqual(response.status_code, http.HTTPStatus.OK)
        self.assertEqual(response.json,
                         dict(
                             services=[
                                 dict(id='s1',
                                      name='service_name',
                                      description='service_description',
                                      bindable=True,
                                      plans=[dict(
                                          id='p1',
                                          name='default',
                                          description='plan_description',
                                          metadata=dict(
                                              displayName='displayName',
                                              bullets=['bullet1'],
                                              costs=[dict(
                                                  amount={'requests': 1},
                                                  unit='unit'
                                              )],
                                              custom_field2='custom_field2'
                                          ),
                                          free=True,
                                          bindable=True
                                      )],
                                      tags=['tag1', 'tag2'],
                                      requires=['something'],
                                      metadata=dict(
                                          displayName='displayName',
                                          imageUrl='imageUrl',
                                          longDescription='longDescription',
                                          providerDisplayName='providerDisplayName',
                                          documentationUrl='documentationUrl',
                                          supportUrl='supportUrl',
                                          shareable=True,
                                          custom_field1='custom_field1'
                                      ),
                                      dashboard_client=dict(
                                          id='id',
                                          secret='secret',
                                          redirect_uri='redirect_uri'
                                      ),
                                      plan_updateable=True
                                      )
                             ]
                         ))

    def test_catalog_returns_200_with_minimal_service_information(self):
        self.broker.catalog.return_value = self.service

        response = self.client.get(
            '/v2/catalog',
            headers={
                'X-Broker-Api-Version': '2.13',
                'X-Broker-Api-Originating-Identity': 'test ' + base64.standard_b64encode(b'{"user_id":123}').decode(
                    'ascii'),
                'Authorization': self.auth_header,
                'unknown': 'unknown'
            })

        self.assertEqual(response.status_code, http.HTTPStatus.OK)
        self.assertEqual(response.json,
                         dict(
                             services=[
                                 dict(
                                     id='s1',
                                     name='service_name',
                                     description='service_description',
                                     bindable=True,
                                     plan_updateable=False,
                                     plans=[dict(id='p1', name='default', description='plan_description')]
                                 )
                             ]
                         ))

    def test_catalog_returns_500_if_error_raised(self):
        self.broker.catalog.side_effect = Exception('ERROR')

        response = self.client.get(
            '/v2/catalog',
            headers={
                'X-Broker-Api-Version': '2.13',
                'Authorization': self.auth_header,
                'unknown': 'unknown'
            })

        self.assertEqual(response.status_code, http.HTTPStatus.INTERNAL_SERVER_ERROR)
        self.assertEqual(response.json,
                         dict(
                             description='ERROR'
                         ))
Ejemplo n.º 17
0
    def test_catalog_returns_200_with_service_information(self):
        '''
        This tests all the possible information a catalog could have. Including custom Service-/ServicePlanMetadata
        '''
        self.broker.catalog.return_value = Service(
            id='s1',
            name='service_name',
            description='service_description',
            bindable=True,
            plans=[ServicePlan(
                id='p1',
                name='default',
                description='plan_description',
                metadata=ServicePlanMetadata(
                    displayName='displayName',
                    bullets=['bullet1'],
                    costs=[ServicePlanCost(
                        amount={'requests': 1},
                        unit='unit'
                    )],
                    custom_field2='custom_field2'
                ),
                free=True,
                bindable=True
            )],
            tags=['tag1', 'tag2'],
            requires=['something'],
            metadata=ServiceMetadata(
                displayName='displayName',
                imageUrl='imageUrl',
                longDescription='longDescription',
                providerDisplayName='providerDisplayName',
                documentationUrl='documentationUrl',
                supportUrl='supportUrl',
                shareable=True,
                custom_field1='custom_field1'
            ),
            dashboard_client=ServiceDashboardClient(
                id='id',
                secret='secret',
                redirect_uri='redirect_uri'
            ),
            plan_updateable=True
        )

        response = self.client.get(
            '/v2/catalog',
            headers={
                'X-Broker-Api-Version': '2.13',
                'Authorization': self.auth_header,
                'unknown': 'unknown'
            })

        self.assertEqual(response.status_code, http.HTTPStatus.OK)
        self.assertEqual(response.json,
                         dict(
                             services=[
                                 dict(id='s1',
                                      name='service_name',
                                      description='service_description',
                                      bindable=True,
                                      plans=[dict(
                                          id='p1',
                                          name='default',
                                          description='plan_description',
                                          metadata=dict(
                                              displayName='displayName',
                                              bullets=['bullet1'],
                                              costs=[dict(
                                                  amount={'requests': 1},
                                                  unit='unit'
                                              )],
                                              custom_field2='custom_field2'
                                          ),
                                          free=True,
                                          bindable=True
                                      )],
                                      tags=['tag1', 'tag2'],
                                      requires=['something'],
                                      metadata=dict(
                                          displayName='displayName',
                                          imageUrl='imageUrl',
                                          longDescription='longDescription',
                                          providerDisplayName='providerDisplayName',
                                          documentationUrl='documentationUrl',
                                          supportUrl='supportUrl',
                                          shareable=True,
                                          custom_field1='custom_field1'
                                      ),
                                      dashboard_client=dict(
                                          id='id',
                                          secret='secret',
                                          redirect_uri='redirect_uri'
                                      ),
                                      plan_updateable=True
                                      )
                             ]
                         ))
Ejemplo n.º 18
0
 def catalog(self):
     return Service(
         id='e636ea62-a613-41a5-88b5-34f7be4b8d34',
         name='tu-host',
         description=
         'Run virtual machine on central, highly available virtualization platform',
         bindable=False,
         metadata=ServiceMetadata(
             displayName='TUhost',
             imageUrl='http://example.com/tuhost_logo.png',
             longDescription=
             'You have the opportunity to operate virtual machines on the central and highly available TU.it virtualisation platform, hosted on VMware ESXi. TUhost is suitable for operating servers with moderate resource requirements, but high availability demands. The virtualisation platform is not suitable for operating servers that are to support applications demanding a particularly high computing capacity and/or storage performance, such as simulation calculations, high-performance databases or storage for vast quantities of data.',
             providerDisplayName='TU.it',
             documentationUrl='https://www.it.tuwien.ac.at/tuhost/',
             supportUrl='https://support.tuwien.ac.at/assystnet/'),
         plans=[
             ServicePlan(
                 id='057997b7-22ac-4d6b-90a9-b2c8d5e289e6',
                 name='standard',
                 description=
                 'Configurable, highly available Virtual Machine.',
                 free=False,
                 bindable=False,
                 metadata=ServicePlanMetaData(
                     displayName='TUhost Standard',
                     bullets=[
                         'Provision of virtual servers including storage for TU organisational units',
                         'Backup for VMs', 'VM administration portal',
                         'Restore option in self-service via a portal'
                     ],
                     costs=[
                         ServicePlanCost(amount={'eur': 8},
                                         unit='vCPU per quarter'),
                         ServicePlanCost(amount={'eur': 8},
                                         unit='GB RAM per quarter'),
                         ServicePlanCost(amount={'eur': 0.1},
                                         unit='GB system disk per quarter'),
                         ServicePlanCost(amount={'eur': 0.1},
                                         unit='GB data disk per quarter'),
                         ServicePlanCost(
                             amount={'eur': 0.25},
                             unit='GB high-performance disk per quarter'),
                     ]),
                 schemas=Schemas(service_instance={
                     'create': {
                         'parameters': {
                             '$schema':
                             'http://json-schema.org/draft-04/schema#',
                             'type': 'object',
                             'properties': {
                                 'vmName': {
                                     'description':
                                     'Virtual machine name (host.subdomain).',
                                     'type': 'string'
                                 },
                                 'vCPUs': {
                                     'description':
                                     'Number of virtual CPUs.',
                                     'type': 'int'
                                 },
                                 'ram': {
                                     'description': 'Amount of RAM in GB.',
                                     'type': 'int'
                                 },
                                 'diskSys': {
                                     'description':
                                     'Amount of system disk storage in GB.',
                                     'type': 'int'
                                 },
                                 'diskData': {
                                     'description':
                                     'Amount of data disk storage in GB.',
                                     'type': 'int'
                                 },
                                 'diskHighPerf': {
                                     'description':
                                     'Amount of high performance disk storage in GB.',
                                     'type': 'int'
                                 },
                                 'os': {
                                     'description':
                                     'Virtual machine operating system.',
                                     'type':
                                     'string',
                                     'enum':
                                     ['CentOS', 'Debian', 'Windows Server']
                                 },
                                 'usage': {
                                     'description':
                                     'Intended usage of the virtual machine.',
                                     'type': 'string'
                                 },
                             }
                         }
                     },
                     'update': {
                         'parameters': {
                             '$schema':
                             'http://json-schema.org/draft-04/schema#',
                             'type': 'object',
                             'properties': {
                                 'vCPUs': {
                                     'description':
                                     'Number of virtual CPUs.',
                                     'type': 'int'
                                 },
                                 'ram': {
                                     'description': 'Amount of RAM in GB.',
                                     'type': 'int'
                                 },
                                 'diskSys': {
                                     'description':
                                     'Amount of system disk storage in GB.',
                                     'type': 'int'
                                 },
                                 'diskData': {
                                     'description':
                                     'Amount of data disk storage in GB.',
                                     'type': 'int'
                                 },
                                 'diskHighPerf': {
                                     'description':
                                     'Amount of high performance disk storage in GB.',
                                     'type': 'int'
                                 },
                             }
                         }
                     }
                 },
                                 service_binding={
                                     'create': {
                                         'parameters': {
                                             '$schema':
                                             'http://json-schema.org/draft-04/schema#',
                                             'type': 'object',
                                             'properties': {
                                                 'xxxx': {
                                                     'description':
                                                     'Some parameter needed for binding the service instance.',
                                                     'type': 'string'
                                                 }
                                             }
                                         }
                                     }
                                 })),
         ],
         tags=['vm', 'virtual-server'],
         plan_updateable=True,
     )