Exemplo n.º 1
0
    def test_index(self, version):
        ss = [
            stub_security_service(self, version, 1),
            stub_security_service(self, version, 2),
        ]
        ctxt = context.RequestContext('admin', 'fake', True)
        request = fakes.HTTPRequest.blank('/security-services?all_tenants=1',
                                          version=version)
        request.headers['X-Openstack-Manila-Api-Version'] = version
        request.environ['manila.context'] = ctxt
        self.mock_object(security_service.db, 'security_service_get_all',
                         mock.Mock(return_value=ss))
        self.mock_object(security_service.db,
                         'share_network_get_all_by_security_service',
                         mock.Mock(return_value=[]))

        ss_controller = security_service.SecurityServiceController()

        result = ss_controller.detail(request)

        self.assertIsInstance(result, dict)
        self.assertEqual(['security_services'], list(result.keys()))
        self.assertIsInstance(result['security_services'], list)
        self.assertEqual(2, len(result['security_services']))
        self.assertIn(ss[0], result['security_services'])

        ss_keys = list(result['security_services'][0].keys())
        if self.is_microversion_ge(version, '2.44'):
            self.assertIn('ou', ss_keys)
        else:
            self.assertNotIn('ou', ss_keys)
Exemplo n.º 2
0
 def setUp(self):
     super(ShareApiTest, self).setUp()
     self.controller = security_service.SecurityServiceController()
     self.maxDiff = None
     self.ss_active_directory = {
         "created_at": "fake-time",
         "updated_at": "fake-time-2",
         "id": 1,
         "name": "fake-name",
         "description": "Fake Security Service Desc",
         "type": constants.SECURITY_SERVICES_ALLOWED_TYPES[0],
         "dns_ip": "1.1.1.1",
         "server": "fake-server",
         "domain": "fake-domain",
         "user": "******",
         "password": "******",
         "status": "new",
         "project_id": "fake",
     }
     self.ss_ldap = {
         "created_at": "fake-time",
         "updated_at": "fake-time-2",
         "id": 2,
         "name": "ss-ldap",
         "description": "Fake Security Service Desc",
         "type": constants.SECURITY_SERVICES_ALLOWED_TYPES[1],
         "dns_ip": "2.2.2.2",
         "server": "test-server",
         "domain": "test-domain",
         "user": "******",
         "password": "******",
         "status": "active",
         "project_id": "fake",
     }
     self.valid_search_opts = {
         'user': '******',
         'server': 'fake-server',
         'dns_ip': '1.1.1.1',
         'domain': 'fake-domain',
         'status': 'new',
         'type': constants.SECURITY_SERVICES_ALLOWED_TYPES[0],
     }
     self.check_policy_patcher = mock.patch(
         'manila.api.v1.security_service.policy.check_policy')
     self.check_policy_patcher.start()
     self.addCleanup(self._stop_started_patcher, self.check_policy_patcher)
     self.security_service_list_expected_resp = {
         'security_services': [
             {
                 'id': self.ss_active_directory['id'],
                 'name': self.ss_active_directory['name'],
                 'type': self.ss_active_directory['type'],
                 'status': self.ss_active_directory['status']
             },
         ]
     }
Exemplo n.º 3
0
 def setUp(self):
     super(ShareApiTest, self).setUp()
     self.controller = security_service.SecurityServiceController()
     self.maxDiff = None
     self.security_service = {
         "created_at": "fake-time",
         "updated_at": "fake-time-2",
         "id": 1,
         "name": "fake-name",
         "description": "Fake Security Service Desc",
         "type": constants.SECURITY_SERVICES_ALLOWED_TYPES[0],
         "dns_ip": "1.1.1.1",
         "server": "fake-server",
         "domain": "fake-domain",
         "user": "******",
         "password": "******",
         "status": "new",
         "project_id": "fake",
     }
     security_service.policy.check_policy = mock.Mock()