Skip to content

Commit

Permalink
Fix misprint in 'delete_playbook_configuration' API permission
Browse files Browse the repository at this point in the history
Change-Id: I6d58ccce6d913db754f802ac50bf13c3645a588a
  • Loading branch information
9seconds committed May 2, 2017
1 parent c3d6f32 commit 06eac73
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This migration fixes incorrect permission name
(confuiguration -> configuration).
"""


from decapod_api import wsgi
from decapod_common.models import db
from decapod_common.models import generic
from decapod_common.models import role


with wsgi.application.app_context():
generic.configure_models(db.MongoDB())

collection = role.RoleModel.collection()
print("Documents: {0}".format(collection.count()))

result = collection.update_many(
{
"permissions": {
"$elemMatch": {
"name": "api",
"permissions": "delete_playbook_confuiguration"
}
}
},
{
"$addToSet": {
"permissions.$.permissions": "delete_playbook_configuration"
}
}
)
print(
"Add correct line: matched={0.matched_count}, "
"modified={0.modified_count}".format(result))

result = collection.update_many(
{
"permissions": {
"$elemMatch": {
"name": "api",
"permissions": "delete_playbook_confuiguration"
}
}
},
{
"$pull": {
"permissions.$.permissions": "delete_playbook_confuiguration"
}
}
)
print(
"Remove failed line: matched={0.matched_count}, "
"modified={0.modified_count}".format(result))
2 changes: 1 addition & 1 deletion backend/api/decapod_api/views/v1/playbook_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def post(self):

return pcmodel

@auth.AUTH.require_authorization("api", "delete_playbook_confuiguration")
@auth.AUTH.require_authorization("api", "delete_playbook_configuration")
@validators.with_model(playbook_configuration.PlaybookConfigurationModel)
def delete(self, item_id, item):
try:
Expand Down
4 changes: 2 additions & 2 deletions decapodlib/decapodlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def create_role(self, name, permissions, **kwargs):
"create_user",
"delete_cluster",
"delete_execution",
"delete_playbook_confuiguration",
"delete_playbook_configuration",
"delete_role",
"delete_server",
"delete_user",
Expand Down Expand Up @@ -1504,7 +1504,7 @@ def get_permissions(self, **kwargs):
"create_user",
"delete_cluster",
"delete_execution",
"delete_playbook_confuiguration",
"delete_playbook_configuration",
"delete_role",
"delete_server",
"delete_user",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ Real-world Example
"create_user",
"delete_cluster",
"delete_execution",
"delete_playbook_confuiguration",
"delete_playbook_configuration",
"delete_role",
"delete_server",
"delete_user",
Expand Down

0 comments on commit 06eac73

Please sign in to comment.