Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manual test for testing role request emails #282

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/Doctrine/deploy/sampleData/NGIs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,17 @@
<SECURITY_EMAIL>[email protected]</SECURITY_EMAIL>
<SITE_COUNT>7</SITE_COUNT>
</NGI>
<NGI PRIMARY_KEY="33001H0" NAME="NGI_FIFE">
<PRIMARY_KEY>33001H0</PRIMARY_KEY>
<NAME>NGI_FIFE</NAME>
<OBJECT_ID>20721</OBJECT_ID>
<DESCRIPTION/>
<EMAIL>[email protected]</EMAIL>
<GGUS_SU/>
<ROD_EMAIL/>
<HELPDESK_EMAIL/>
<SECURITY_EMAIL>[email protected]</SECURITY_EMAIL>
<SITE_COUNT>7</SITE_COUNT>
</NGI>

</results>
61 changes: 15 additions & 46 deletions lib/Doctrine/deploy/sampleData/UsersAndRoles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<DESCRIPTION>
</DESCRIPTION>
<GOCDB_PORTAL_URL>https://testing.host.com/portal/index.php?Page_Type=View_Object&amp;object_id=6653&amp;grid_id=0</GOCDB_PORTAL_URL>
<EMAIL>sample@sample.com</EMAIL>
<EMAIL>GriffinPeterson@sample.com</EMAIL>
<TEL>+49 7247 82 0000</TEL>
<WORKING_HOURS_START></WORKING_HOURS_START>
<WORKING_HOURS_END></WORKING_HOURS_END>
Expand All @@ -18,8 +18,8 @@
<ACTIVE></ACTIVE>
<HOMESITE>SWITCH</HOMESITE>
<USER_ROLE>
<USER_ROLE>Regional Staff (ROD)</USER_ROLE>
<ON_ENTITY>NGI_CH</ON_ENTITY>
<USER_ROLE>EGI CSIRT Officer</USER_ROLE>
<ON_ENTITY>EGI</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
</EGEE_USER>
Expand All @@ -31,35 +31,19 @@
<TITLE></TITLE>
<DESCRIPTION></DESCRIPTION>
<GOCDB_PORTAL_URL>https://testing.host.com/portal/index.php?Page_Type=View_Object&amp;object_id=6326&amp;grid_id=0</GOCDB_PORTAL_URL>
<EMAIL>sample@sample.com</EMAIL>
<EMAIL>AmyWong@sample.com</EMAIL>
<TEL>+49 040 0000 1763</TEL>
<WORKING_HOURS_START></WORKING_HOURS_START>
<WORKING_HOURS_END></WORKING_HOURS_END>
<CERTDN>/C=00/O=00000/OU=000000/CN=Amy Wong</CERTDN>
<APPROVED></APPROVED>
<ACTIVE></ACTIVE>
<HOMESITE>T3_CH_PSI</HOMESITE>

<USER_ROLE>
<USER_ROLE>CIC Staff</USER_ROLE>
<ON_ENTITY>EGI</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
<USER_ROLE>
<USER_ROLE>COD Staff</USER_ROLE>
<USER_ROLE>Chief Operations Officer</USER_ROLE>
<ON_ENTITY>EGI</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
<USER_ROLE>
<USER_ROLE>Regional Staff (ROD)</USER_ROLE>
<ON_ENTITY>NGI_CH</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
<USER_ROLE>
<USER_ROLE>Site Operations Manager</USER_ROLE>
<ON_ENTITY>NGI_CH</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
</EGEE_USER>

<EGEE_USER USER_ID="154512" PRIMARY_KEY="784G0">
Expand All @@ -68,7 +52,7 @@
<TITLE></TITLE>
<DESCRIPTION></DESCRIPTION>
<GOCDB_PORTAL_URL>https://testing.host.com/portal/index.php?Page_Type=View_Object&amp;object_id=6326&amp;grid_id=0</GOCDB_PORTAL_URL>
<EMAIL>sample@sample.com</EMAIL>
<EMAIL>NevilleLongbottom@sample.com</EMAIL>
<TEL>+49 040 0000 1763</TEL>
<WORKING_HOURS_START></WORKING_HOURS_START>
<WORKING_HOURS_END></WORKING_HOURS_END>
Expand All @@ -78,22 +62,7 @@
<HOMESITE>UZH</HOMESITE>

<USER_ROLE>
<USER_ROLE>CIC Staff</USER_ROLE>
<ON_ENTITY>EGI</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
<USER_ROLE>
<USER_ROLE>COD Staff</USER_ROLE>
<ON_ENTITY>EGI</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
<USER_ROLE>
<USER_ROLE>Regional Staff (ROD)</USER_ROLE>
<ON_ENTITY>NGI_CH</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
<USER_ROLE>
<USER_ROLE>Site Operations Manager</USER_ROLE>
<USER_ROLE>NGI Operations Manager</USER_ROLE>
<ON_ENTITY>NGI_CH</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
Expand All @@ -106,7 +75,7 @@
<TITLE></TITLE>
<DESCRIPTION></DESCRIPTION>
<GOCDB_PORTAL_URL>https://testing.host.com/portal/index.php?Page_Type=View_Object&amp;object_id=6326&amp;grid_id=0</GOCDB_PORTAL_URL>
<EMAIL>sample@sample.com</EMAIL>
<EMAIL>DonnaMoss@sample.com</EMAIL>
<TEL>+49 040 0000 1763</TEL>
<WORKING_HOURS_START></WORKING_HOURS_START>
<WORKING_HOURS_END></WORKING_HOURS_END>
Expand All @@ -116,10 +85,15 @@
<HOMESITE>UNIBE-LHEP</HOMESITE>

<USER_ROLE>
<USER_ROLE>COD Staff</USER_ROLE>
<USER_ROLE>Regional Staff (ROD)</USER_ROLE>
<ON_ENTITY>NGI_CH</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
<USER_ROLE>
<USER_ROLE>Site Operations Manager</USER_ROLE>
<ON_ENTITY>UNIBE-LHEP</ON_ENTITY>
<ENTITY_TYPE>site</ENTITY_TYPE>
</USER_ROLE>
</EGEE_USER>

<EGEE_USER USER_ID="154512" PRIMARY_KEY="7544G0">
Expand All @@ -128,7 +102,7 @@
<TITLE></TITLE>
<DESCRIPTION></DESCRIPTION>
<GOCDB_PORTAL_URL>https://testing.host.com/portal/index.php?Page_Type=View_Object&amp;object_id=6326&amp;grid_id=0</GOCDB_PORTAL_URL>
<EMAIL>sample@sample.com</EMAIL>
<EMAIL>RichardWinters@sample.com</EMAIL>
<TEL>+49 040 0000 1763</TEL>
<WORKING_HOURS_START></WORKING_HOURS_START>
<WORKING_HOURS_END></WORKING_HOURS_END>
Expand All @@ -137,10 +111,5 @@
<ACTIVE></ACTIVE>
<HOMESITE>UNIGE-DPNC</HOMESITE>

<USER_ROLE>
<USER_ROLE>COD Staff</USER_ROLE>
<ON_ENTITY>NGI_CH</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
</EGEE_USER>
</results>
77 changes: 77 additions & 0 deletions tests/manualTests/TestRoleRequestEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

# This is designed to sanity check the role request email functionality.
# It is not a unit test, it is designed to be run against the sample data.
# Usage: php tests/manualTests/TestRoleRequestEmail.php
require_once 'lib/Gocdb_Services/NotificationService.php';

$requesting_user_id = 5; // This corresponds to Richard Winters.
$requesting_user = \Factory::getUserService()->getUser($requesting_user_id);

echo "=====================================================================\n";
# Test 1, requesting a role over a site with existing role approvers

$site_id = 5; // This corresponds to UNIBE-LHEP
# Get Site object from above ID.
$site = \Factory::getSiteService()->getSite($site_id);

# Have Richard appear to request the "Site Operations Manager" role over
# UNIBE-LHEP. This request should go to Donna, who also has the
# "Site Operations Manager" role.
$role_requested = new \Role(
new \RoleType("Site Operations Manager"),
$requesting_user, $site, RoleStatus::PENDING);

$notificationService = \Factory::getNotificationService();
$notificationService->roleRequest($role_requested, $requesting_user, $site);

echo "=====================================================================\n";
# Test 2, requesting a role over a site with no existing role approvers.
$site_id = 6; // This corresponds to T3_CH_PSI
# Get Site object from above ID.
$site = \Factory::getSiteService()->getSite($site_id);

# Have Richard appear to request the "Site Operations Manager" role over
# T3_CH_PSI. As this Site has no one with a role over it the request should
# email Neville (NGI Operations Manager of NGI_CH) but not Donna (who cannot
# approve the role as "Regional Staff (ROD)")
$role_requested = new \Role(
new \RoleType("Site Operations Manager"),
$requesting_user, $site, RoleStatus::PENDING);

$notificationService = \Factory::getNotificationService();
$notificationService->roleRequest($role_requested, $requesting_user, $site);

echo "=====================================================================\n";
# Test 3, requesting a role over a NGI with existing role approvers.
$ngi_id = 2; // This corresponds to NGI_CH
# Get Site object from above ID.
$ngi = \Factory::getNgiService()->getNgi($ngi_id);

# Have Richard appear to request the "NGI Operations Manager" role over
# NGI_CH. This request should go to Neville, who also has the
# "NGI Operations Manager" role but not Donna (who cannot approve the role as
# "Regional Staff (ROD)")
$role_requested = new \Role(
new \RoleType("NGI Operations Manager"),
$requesting_user, $ngi, RoleStatus::PENDING);

$notificationService = \Factory::getNotificationService();
$notificationService->roleRequest($role_requested, $requesting_user, $ngi);

echo "=====================================================================\n";
# Test 4, requesting a role over a site with no existing role approvers.
$ngi_id = 3; // This corresponds to NGI_FIFE
# Get Site object from above ID.
$ngi = \Factory::getNgiService()->getNgi($ngi_id);

# Have Richard appear to request the "NGI Operations Manager" role over
# NGI_CH. This request should go to Griffin and Amy, who have Project roles.
$role_requested = new \Role(
new \RoleType("NGI Operations Manager"),
$requesting_user, $ngi, RoleStatus::PENDING);

$notificationService = \Factory::getNotificationService();
$notificationService->roleRequest($role_requested, $requesting_user, $ngi);

?>