Skip to content

Commit

Permalink
Grant organizer role to co-organizers #3
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorwolf committed Oct 12, 2016
1 parent 1ad85e2 commit 968a74d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
9 changes: 6 additions & 3 deletions odataorganizer/procedures/CoOrganizerCreate.hdbprocedure
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ BEGIN
AND "History.CreatedBy" = lv_CreatedBy;

IF lv_Count = 1 THEN
INSERT INTO "com.sap.sapmentors.sitreg.data::SITreg.CoOrganizer"
VALUES(
lv_EventID
INSERT INTO "com.sap.sapmentors.sitreg.data::SITreg.CoOrganizer"
VALUES(
lv_EventID
, UCASE( lv_UserName )
, lv_CreatedBy
, CURRENT_TIMESTAMP
, lv_CreatedBy
, CURRENT_TIMESTAMP
, lv_Active
);
CALL "SITREG"."com.sap.sapmentors.sitreg.odataorganizer.procedures::GrantOrganizerRoleToUser" (
USERNAME => UCASE( lv_UserName )
);
ELSE
error = SELECT 400 AS http_status_code,
'Event does not belong to you' AS error_message,
Expand Down
26 changes: 26 additions & 0 deletions odataorganizer/procedures/GrantOrganizerRoleToUser.hdbprocedure
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--
-- Copyright 2016 SAP Mentors
--
-- 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.
--
PROCEDURE "SITREG"."com.sap.sapmentors.sitreg.odataorganizer.procedures::GrantOrganizerRoleToUser" (
IN USERNAME VARCHAR(256)
)
LANGUAGE SQLSCRIPT
SQL SECURITY DEFINER
DEFAULT SCHEMA SITREG
AS
ROLENAME VARCHAR(256) := 'com.sap.sapmentors.sitreg.roles::organizer';
BEGIN
CALL "_SYS_REPO"."GRANT_ACTIVATED_ROLE"(ROLENAME => ROLENAME, USERNAME => USERNAME);
END
8 changes: 5 additions & 3 deletions roles/organizer.hdbrole
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
role com.sap.sapmentors.sitreg.roles::organizer {
// catalog schema "SITREG": SELECT;
sql object com.sap.sapmentors.sitreg.data::eventId: SELECT;
sql object com.sap.sapmentors.sitreg.data::SITreg.Event: SELECT, INSERT, UPDATE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::EventCreate: EXECUTE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::EventUpdate: EXECUTE;
sql object com.sap.sapmentors.sitreg.data::SITreg.Device: SELECT, INSERT, UPDATE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::DeviceCreate: EXECUTE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::DeviceUpdate: EXECUTE;
Expand All @@ -13,9 +16,8 @@ role com.sap.sapmentors.sitreg.roles::organizer {
sql object com.sap.sapmentors.sitreg.data::SITreg.CoOrganizer: SELECT, INSERT, UPDATE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::CoOrganizerCreate: EXECUTE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::CoOrganizerUpdate: EXECUTE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::EventCreate: EXECUTE;
sql object com.sap.sapmentors.sitreg.data::eventId: SELECT;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::EventUpdate: EXECUTE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::CoOrganizerUpdate: EXECUTE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::GrantOrganizerRoleToUser: EXECUTE;
sql object com.sap.sapmentors.sitreg.odataorganizer.procedures::UpdateWaitingList: EXECUTE;

application privilege: "com.sap.sapmentors.sitreg.odataorganizer::organizer";
Expand Down
7 changes: 3 additions & 4 deletions test/procedures/setup.hdbprocedure
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ BEGIN
DELETE FROM "com.sap.sapmentors.sitreg.data::SITreg.Organizer"
WHERE "History.CreatedBy" = 'PARTICIPANT';

CALL _SYS_REPO.GRANT_ACTIVATED_ROLE ('com.sap.sapmentors.sitreg.roles::organizer','ORGANIZER');
CALL _SYS_REPO.GRANT_ACTIVATED_ROLE ('com.sap.sapmentors.sitreg.roles::organizer','COORGANIZER');
CALL _SYS_REPO.GRANT_ACTIVATED_ROLE ('com.sap.sapmentors.sitreg.roles::participant','COORGANIZER');
CALL _SYS_REPO.GRANT_ACTIVATED_ROLE ('com.sap.sapmentors.sitreg.roles::participant','PARTICIPANT');
CALL _SYS_REPO.GRANT_ACTIVATED_ROLE ('com.sap.sapmentors.sitreg.roles::organizer', 'ORGANIZER' );
CALL _SYS_REPO.GRANT_ACTIVATED_ROLE ('com.sap.sapmentors.sitreg.roles::participant', 'COORGANIZER' );
CALL _SYS_REPO.GRANT_ACTIVATED_ROLE ('com.sap.sapmentors.sitreg.roles::participant', 'PARTICIPANT' );
CALL _SYS_REPO.GRANT_ACTIVATED_ROLE ('com.sap.sapmentors.sitreg.roles::receptionist','RECEPTIONIST');

END
3 changes: 1 addition & 2 deletions test/spec/Organizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,12 @@ describe("Add COORGANIZER to event", function() {

describe("Add additional co-organizers to event", function() {
it("should add additional co-organizers to event", function() {
var xhr = addCoOrganizer(eventID, "XSA_DEV");
xhr = addCoOrganizer(eventIDsmall, "COORGANIZER");
expect(xhr.status).toBe(201);
expect(xhr.statusText).toBe("Created");
xhr = addCoOrganizer(eventID, "GWOLF");
xhr = addCoOrganizer(eventID, "S0001142741");
xhr = addCoOrganizer(eventIDsmall, "S0001142741");
xhr = addCoOrganizer(eventIDsmall, "COORGANIZER");
});
});

Expand Down

0 comments on commit 968a74d

Please sign in to comment.