Skip to content

Commit d70eb97

Browse files
author
Luiko Czub
committed
new api method - setUserRoleOnProject #141
1 parent c1073f6 commit d70eb97

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

example/TestLinkExampleGenericApi.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ def checkUser(name1, name2):
185185
print("createTestProject", newProject)
186186
newProjectID = newProject[0]['id']
187187
print("New Project '%s' - id: %s" % (NEWPROJECT,newProjectID))
188+
189+
# assign project roles to user
190+
response = myTestLink.setUserRoleOnProject(myTestUser1_ID, "tester", newProjectID)
191+
print("setUserRoleOnProject user1", response)
192+
response = myTestLink.setUserRoleOnProject(myTestUser2_ID, "senior tester", newProjectID)
193+
print("setUserRoleOnProject user2 role a", response)
194+
response = myTestLink.setUserRoleOnProject(myTestUser2_ID, "test designer", newProjectID)
195+
print("setUserRoleOnProject user2 role b", response)
196+
# get user information
197+
response = myTestLink.getUserByID(myTestUser1_ID)
198+
print("getUserByID user1", response)
199+
response = myTestLink.getUserByID(myTestUser2_ID)
200+
print("getUserByID user2", response)
201+
188202

189203
# Create test plan A - uses platforms
190204
newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN_A, testprojectname=NEWPROJECT,

src/testlink/testlinkapigeneric.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,27 @@ def getAllExecutionsResults(self):
20932093
def createUser(self):
20942094
""" Create a new user """
20952095

2096+
# /**
2097+
# * Set a role to a user at project level
2098+
# *
2099+
# * Restricted to users with System Wide Role Admin
2100+
# *
2101+
# * @param struct $args
2102+
# * @param struct $args["userid"]
2103+
# * @param struct $args["rolename"]
2104+
# * @param struct $args["testprojectid"]
2105+
# *
2106+
# * @return true if OK, otherwise error structure
2107+
# *
2108+
# * @access public
2109+
# */
2110+
# public function setUserRoleOnProject($args)
2111+
@decoApiCallAddDevKey
2112+
@decoMakerApiCallWithArgs(['userid', 'rolename', 'testprojectid'])
2113+
def setUserRoleOnProject(self):
2114+
""" Set a role to a user at project level
2115+
Restricted to users with System Wide Role Admin
2116+
"""
20962117

20972118
#
20982119
# internal methods for general server calls

test/utest-offline/test_apiClients_whatArgs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def test_whatArgs_unknownMethods(api_client):
114114
'platformonexecution=<platformonexecution>']),
115115
('closeBuild', ['<buildid>']),
116116
('createUser', ['<login>', '<firstname>', '<lastname>', '<email>',
117-
'password=<password>'])
117+
'password=<password>']),
118+
('setUserRoleOnProject', ['<userid>', '<rolename>', '<testprojectid>'])
118119
]
119120

120121
@pytest.mark.parametrize("apiCall, descriptions",

0 commit comments

Comments
 (0)