pbs_acl_groups.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # coding: utf-8
  2. # Copyright (C) 1994-2018 Altair Engineering, Inc.
  3. # For more information, contact Altair at www.altair.com.
  4. #
  5. # This file is part of the PBS Professional ("PBS Pro") software.
  6. #
  7. # Open Source License Information:
  8. #
  9. # PBS Pro is free software. You can redistribute it and/or modify it under the
  10. # terms of the GNU Affero General Public License as published by the Free
  11. # Software Foundation, either version 3 of the License, or (at your option) any
  12. # later version.
  13. #
  14. # PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
  15. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. # FOR A PARTICULAR PURPOSE.
  17. # See the GNU Affero General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Affero General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. # Commercial License Information:
  23. #
  24. # For a copy of the commercial license terms and conditions,
  25. # go to: (http://www.pbspro.com/UserArea/agreement.html)
  26. # or contact the Altair Legal Department.
  27. #
  28. # Altair’s dual-license business model allows companies, individuals, and
  29. # organizations to create proprietary derivative works of PBS Pro and
  30. # distribute them - whether embedded or bundled with other software -
  31. # under a commercial license agreement.
  32. #
  33. # Use of Altair’s trademarks, including but not limited to "PBS™",
  34. # "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
  35. # trademark licensing policies.
  36. from tests.functional import *
  37. class Test_acl_groups(TestFunctional):
  38. """
  39. Test to check acl_groups and acl_resv_groups considers secondary group
  40. """
  41. def test_acl_grp_queue(self):
  42. """
  43. Set acl_groups on a queue and submit a job with a user
  44. for whom the set group is a secondary group
  45. """
  46. a = {'queue_type': 'execution', 'started': 't', 'enabled': 't',
  47. 'acl_group_enable': 't', 'acl_groups': TSTGRP1}
  48. self.server.manager(MGR_CMD_CREATE, QUEUE, a, id='workq2')
  49. a = {'queue': 'workq2'}
  50. j = Job(TEST_USER1, attrs=a)
  51. # If 'Unauthorized Request' is found in error message the test would
  52. # fail as user was not able to submit job as a secondary group member
  53. try:
  54. jid = self.server.submit(j)
  55. except PbsSubmitError as e:
  56. self.assertFalse('Unauthorized Request' in e.msg[0])
  57. def test_acl_resv_groups(self):
  58. """
  59. Set acl_resv_groups on server and submit a reservation
  60. from a user for whom the set group is a secondary group
  61. """
  62. self.server.manager(MGR_CMD_SET, SERVER, {
  63. 'acl_resv_group_enable': 'true'})
  64. self.server.manager(MGR_CMD_SET, SERVER, {'acl_resv_groups': TSTGRP1})
  65. # If 'Requestor's group not authorized' is found in error message the
  66. # test would fail as user was not able to submit reservation
  67. # as a secondary group member
  68. try:
  69. r = Reservation(TEST_USER1)
  70. rstart = int(time.time()) + 10
  71. rend = int(time.time()) + 360
  72. a = {'reserve_start': rstart,
  73. 'reserve_end': rend}
  74. r.set_attributes(a)
  75. rid = self.server.submit(r)
  76. except PbsSubmitError as e:
  77. self.assertFalse(
  78. 'Requestor\'s group not authorized' in e.msg[0])