"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sahara/tests/unit/api/test_acl.py" between
sahara-14.0.0.tar.gz and sahara-15.0.0.tar.gz

About: OpenStack Sahara provides an ability to provision, start, shutdown, scale Hadoop cluster on OpenStack.
The "Xena" series (latest release).

test_acl.py  (sahara-14.0.0):test_acl.py  (sahara-15.0.0)
skipping to change at line 16 skipping to change at line 16
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. # implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from unittest import mock
from oslo_policy import policy as cpolicy from oslo_policy import policy as cpolicy
from sahara.api import acl from sahara.api import acl
from sahara import exceptions as ex from sahara import exceptions as ex
from sahara.tests.unit import base from sahara.tests.unit import base
class TestAcl(base.SaharaTestCase): class TestAcl(base.SaharaTestCase):
def _set_policy(self, json): def _set_policy(self, json):
acl.setup_policy() acl.setup_policy()
rules = cpolicy.Rules.load_json(json) rules = cpolicy.Rules.load_json(json)
acl.ENFORCER.set_rules(rules, use_conf=False) acl.ENFORCER.set_rules(rules, use_conf=False)
def test_policy_allow(self): @mock.patch('oslo_config.cfg.ConfigOpts.find_file')
def test_policy_allow(self, mock_config):
mock_config.return_value = '/etc/sahara/'
@acl.enforce("data-processing:clusters:get_all") @acl.enforce("data-processing:clusters:get_all")
def test(): def test():
pass pass
json = '{"data-processing:clusters:get_all": ""}' json = '{"data-processing:clusters:get_all": ""}'
self._set_policy(json) self._set_policy(json)
test() test()
def test_policy_deny(self): @mock.patch('oslo_config.cfg.ConfigOpts.find_file')
def test_policy_deny(self, mock_config):
mock_config.return_value = '/etc/sahara/'
@acl.enforce("data-processing:clusters:get_all") @acl.enforce("data-processing:clusters:get_all")
def test(): def test():
pass pass
json = '{"data-processing:clusters:get_all": "!"}' json = '{"data-processing:clusters:get_all": "!"}'
self._set_policy(json) self._set_policy(json)
self.assertRaises(ex.Forbidden, test) self.assertRaises(ex.Forbidden, test)
 End of changes. 3 change blocks. 
2 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)