Commit Graph

20 Commits

Author SHA1 Message Date
Kiran Pawar 858939c190 Add 'default_ad_site' field to security service object
Allows to configure optional field 'default_ad_site' from version 2.76.
Restrict to make sure either server or 'default_at_site' provided, but
not both.

APIImpact
Relates-bug: #1988146

Change-Id: I8e21e9170eace134a51efed84de1ccc58eb7eaaa
2023-02-16 09:28:28 +00:00
Cameron Kolodjski 3fb9b981b0 Remove admin context check, update unit tests
In manila/api/v1/security_service.py, the context.is_admin check is
removed, allowing the subsequent policy check to determine whether the
user can retrieve all security services. Authorization is determined by
the RBAC policy "security_services:get_all_security_services".

In manila/tests/api/v1/test_security_service.py, unit tests for listing
security services based on admin context were replaced with unit tests
for listing security services based on whether the user is authorized or
not.

The unit test test_security_services_list_all_tenants_policy_authorized
asserts that the security services are retrieved when
policy.check_policy returns True.

The unit test
test_security_services_list_all_tenants_policy_not_authorized asserts
that security services are not retrieved when policy.check_policy
raises a NotAuthorized exception.

Closes-Bug: #1916102

Change-Id: I6cce61237f5ee3ce60d8165f6fac5e7e5a63b4dd
Depends-On: https://review.opendev.org/c/openstack/manila-tempest-plugin/+/840727
2022-05-06 17:14:29 -03:00
haixin 3831e5500f remove usage of six library from unit tests
Replace six with Python 3 style code.

Change-Id: I5077e71663f6b60bd774f30fcf64b36d4078cf8e
2021-01-28 10:47:40 +08:00
Goutham Pacha Ravi 598223985a Use unittest.mock instead of third party lib
mock was adopted into standard python
in version 3.3 [1]. Since manila no longer
supports python2.7, we can use the inbuilt
mock package rather than the third party
lib.

Fix some issues with imports that weren't
following our import conventions of grouping
imports [3]

Add a hacking test to ensure we don't regress
on this.

[1] https://docs.python.org/3/library/unittest.mock.html
[2] http://lists.openstack.org/pipermail/openstack-discuss/2020-March/013281.html
[3] https://docs.openstack.org/hacking/latest/user/hacking.html#imports

Co-Authored-By: Sean McGinnis <sean.mcginnis@gmail.com>
Change-Id: If857a49fbf526983e712282a25d7e8bef5093533
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2020-04-17 16:24:27 -07:00
silvacarloss 14d3e268a0 Add share network with multiple subnets
This patch adds the possibility to create share networks with
multiple subnets in Manila. It also updates the share server api
to receive "share_network_subnet_id" instead of "share_network_id".

Each share network subnet must be associated with only one
availability zone. Each share network must have a single default
share network subnet.

DocImpact
APIImpact
Depends-On: I13bb48e7c03e16c26946ccf9d48e80592391a3d1
Partially-implements: bp share-network-multiple-subnets
Change-Id: Id8814a8b26c9b9dcb1fe71d0d7e9b79e8b8a9210
Closes-Bug: #1588144
Co-Authored-By: lseki <luciomitsuru.seki@fit-tecnologia.org.br>
Co-Authored-By: dviroel <viroel@gmail.com>
2019-09-13 11:27:18 -03:00
zhangqing bb8859f8ac Check all_tenants value in security_service api
Add manila.utils.is_all_tenants to check all_tenants value.

Partial-Bug: #1777551
Co-Authored-By: Yu Weizhong <yuweizhong@cmss.chinamobile.com>
Change-Id: I1c8068cb0d4652f1f0349dc5a8d0a2d3af2318e0
2019-03-19 13:30:58 -07:00
Jiao Pengju 9f69258cab Fix getting share networks and security services error
It will fail when non-admin tenants try to get share networks
and security services with option '{all_tenants: 1}'.
The reason is that the policy of 'get_all_share_networks' and
'get_all_security_services' are admin api, they do not allow
the non-admin tenants list the share networks and security
services with all_tenants=1. This patch removes the policy check
of non-admin tenants and allows non-admin tenants to request to
list with 'all_tenants=1', however 'all_tenants' in the request
is just ignored.

Change-Id: Ied021b66333f1254cd232bbc38562a4a9b762ad2
Co-Authored-By: Goutham Pacha Ravi <gouthampravi@gmail.com>
Related-Bug: #1721787
2017-12-18 09:17:40 +08:00
Yusuke Hayashi 42ecc84a2c Fix order of arguments in assertEqual
Fix incorrect order assertEqual(observed, expected) as below.
  assertEqual(observed, expected) => assertEqual(expected, observed)

Target of this patch:
  manila/tests/api/*

Note:
I also fix following asserts aruond above fixed parts.
  assertEqual(xx, True), assertEqual(True, xx) => assertTrue(xx)

As for assertFalse,
I do not convert assertEqual(xx, False) to assertFalse(xx)
because assertFalse(None) does not raise exception.

Change-Id: I8131946efef654235b5e32344b3f5e42ab3d3ced
Partial-Bug: #1259292
2015-09-29 19:56:49 +09:00
Valeriy Ponomaryov df6ca7ee5f Fix policy check for API 'security service update'
Manila API for update of security service reads policy for "show" operation
but should do it for "update" operation.

Change-Id: I675f834fcb75f3b7864094601e47c15f60a0864b
Closes-Bug: #1459631
2015-05-28 19:20:35 +03:00
Valeriy Ponomaryov eff9f92f01 Remove unused attr status from models
Models "security_services" and "network_allocations" have attr "status" that is
not used indeed. So, remove it from models and add appropriate migrations.

Closes-Bug: #1459660
Change-Id: Idb3a69916e8052b16c9daebb9bb67b09d1714c46
2015-05-28 19:07:45 +03:00
Clinton Knight 65d1158526 Replace legacy StubOutForTesting class
The Manila test module uses a class called StubOutForTesting, which
is an awkward holdover from when the unit tests were using Mox.
Alex wrote a more elegant and capable mocker method,
manila.test.TestCase.mock_object, in the Cinder project which we
have now added to Manila. So to remove the duplicate functionality
and legacy code, all references to self.stubs.Set() in the Manila
tests should be replaced with self.mock_object() and any related
dead code should be removed.

Resolves-bug: #1415602
Change-Id: Ie5f203c0b2cb57ad00d9ec8db0529075b6fef261
2015-02-03 14:31:17 +00:00
Julia Varlamova f3289eb610 Add new search options for security service
We can filter security services only by status, name, id and type now.

Add new search options:
    user,
    server,
    dns_ip,
    domain
to _get_security_services in SecurityServiceController to be able to filter
security services by these fields.

Allow filtering security services by share network id.

Add information about share networks to result if 'detailed' mode enabled.

Add unit and tempest tests for filtering security services.

Implements bp improve-security-service-list-filtering

Change-Id: I8b3845c2d705188ec1dc0db33c1e20c8e6c5e559
2014-10-16 11:16:22 +04:00
Julia Varlamova 0f5b706592 Don't allow security service to be updated if used
When we attach security service to share network and create
share server associated with this share network, security service
or share-network should not be updated as well as deleted.

For update should be available only 'name' and 'description' fields.

Don't allow to remove assigned security-service from share-network
when share-servers exist.

Add unit and tempest tests.

Change-Id: Ide82edea355030b281dc709f8545abfd0fcd13fb
Closes-bug: #1357355
2014-09-10 09:42:32 +04:00
Valeriy Ponomaryov 1de1a187d5 Rename 'sid' to 'user' in access rules and sec services
Rename 'sid' (secure identifier) to 'user' for better understanding by user.
Changed parts:
- db entities
- db migration
- share access rule type
- security services
- tempest tests

Change-Id: I527064508f13bd4dc658746970c2606098199c1c
2014-08-15 13:29:40 +00:00
Yulia Portnova 60211c5ff3 Teardown/setup server enhancements
1. Manager: pass neutron_net_id and neutron_subnet_id in
network_info to setup_server. Pass server_details and
security_services separately to teardown_server

2. Drivers: renamed setup_network/teardown_network methods
to setup_server/teardown_server

3. Generic: pass server backend_details to
set_up_service_instance and delete_service_instance

4 Service_instance: removed passing share_network_id to
setup_server. Return router_id and subnet_id from setup_server.
Added readable naming to service_subnet

Partially-Implements bp setup-teardown-server-enhancements
Change-Id: I9f5ff26fa2635e352043aedf8dde3514deaaba30
2014-07-04 13:10:06 +03:00
Yulia Portnova b2fd5e6223 Checking security service is not used while deleting
Added db method share_network_get_all_by_security_service that
returns all share networks to which security service is assigned.

Added check to delete method in security service api that
gets list of share networks that security service is assigned at
and raises error if this list is not empty.

Closes-bug: 1304473

Change-Id: Ibb73f77095b035f33376aa1791448de3a1ed939b
2014-04-16 10:15:15 -04:00
vponomaryov 05fa0cc9c8 Added type field to security services index list
Current index has only 'name', 'id' and 'status', and
it will be very useful to have additional key - 'type'.

Change-Id: I647a923ed59aa971e15669d7c9239967c815ea09
2014-04-04 08:12:51 -04:00
vponomaryov fa1907acc6 Fixed detail list for security-services
Change-Id: I9f981a6bdefec64228a04fa0a9f15b5f563392cd
Closes-bug: 1297209
2014-03-25 16:15:50 +02:00
Aleks Chirko 8a229a2c6e Add 'password' field to the security service
Change-Id: I8a6d146645b33d7baff52902b7187b09cdbdf63a
2014-01-23 13:33:36 +02:00
Yulia Portnova d68efa454c Security service API
Added security service controller to
Manila v1 API.

Partially implements bp: join-tenant-network
Change-Id: Ic11feb44547bf438d925261b587edc828eac31c1
2014-01-13 15:34:48 +00:00