Mantis Bugtracker          
testlink.org

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001890TestLinkAPI - XMLRPCpublic2008-11-19 22:132010-10-09 08:01
Reporterpartymungo 
Assigned Tofman 
PrioritynormalSeverityfeature requestReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version1.8 RC 1 
Fixed in Version1.9 RC 1 
Summary0001890: Possibility to add attachment by using API
DescriptionHi,
would be very helpful to have the possibility to attachments by using the API. Maybe an enhancement for "reportTCResult".
TagsNo tags attached.
Database (MySQL,Postgres,etc)
BrowserFirefox 2.0.0.17
PHP Version
TestCaseID
QA Team - Task Workflow Status
Attached Files? file icon xmlrpc.class.php [^] (160,982 bytes) 2010-09-17 18:54
? file icon tlAttachmentRepository.class.php [^] (16,148 bytes) 2010-09-17 18:54
zip file icon testlinkunittests.zip [^] (5,249 bytes) 2010-09-17 18:54

- Relationships

-  Notes
(0004666)
azl (administrator)
2008-11-20 05:01

This should probably be put on the schedule for a post 1.8 release, possibly 1.9.
(0004671)
partymungo (reporter)
2008-11-20 15:48

OK, thanks for info. Currently i will pass them directly to db
(only a workaround ;-)).
(0009623)
fman (administrator)
2010-04-05 14:58

Reminder sent to: austvik

I would like to know if you would like to contribute with this issue. If answer if yes write down here a technical anailys for this implementattion.

thanks
(0009625)
austvik (reporter)
2010-04-05 17:57

It is not on the top of my list, but if nobody beats me to it, this is how I would do it.

tl.reportTCResult returns the execution ID. I think we need one TL API call to add one attachment, and then this call could be used many times for each report ID if wanted.

I also see that the attachment code in TL is very general, so we should probably make this call general as well, but then the user/role/rights checking have to be good.

One new call:
tl.addAttachment

Parameters:
attached_to_id (e.g. the id of the test execution)
attached_to_type (e.g. "executions", "node_hierarchy")
file_name (name of the file that is uploaded)
file_path (path of the file that is uploaded
data (the data in this attachment)
Optional parameters:
title (The title of this attachment, optional, default to file name)
description (Description of the content, optional, default to empty)
file_type (mime type of file, optional, defaults to application/octet-stream)
Returns
attachment_id

Then there is probably only a question of time before somebody asks for tl.getAttachments(attachment_to_type, attachment_to_id) => (attachment_id, file_name, file_path, tile_type, title, description) and tl.getAttachmentData(attachment_id) :)
(0009628)
fman (administrator)
2010-04-06 01:00

1. on API getTestCaseAttachments() already exists.
2. new method addAttachment() will be used NOT ONLY to attach files to executions.
3. regarding other requests -> we will wait for it, right now is better to develop this one.

4. please use following names
instead of: attached_to_id => item_id
attached_to_type => item_type

5. why do we need:
file_name (name of the file that is uploaded)
file_path (path of the file that is uploaded

one parameter is not enough ? => pathname

6. how data will be encoded for transmission ? base64 ?

7. you need to provide also the sample PHP client to test this method.
(0009962)
austvik (reporter)
2010-05-09 01:18

4 + 5:

I started on this, and think that instead of item_id/item_type, it would be better to just set 'testcaseid', 'testplanid', 'testsuiteid', 'testprojectid', 'buildid', 'executionid' or 'platformid' (etc), then use the correct check* methods on them, and then connect to an element of that correct type.

6: Agree, XML RPL base64 looks like a good alternative.

I do not plan to work further on this until I know the full picture of how test execution is planned.
(0009963)
fman (administrator)
2010-05-09 16:40

>>
>> I started on this, and think that instead of item_id/item_type, it would be
>> better to just set 'testcaseid', 'testplanid', 'testsuiteid', 'testprojectid', >> 'buildid', 'executionid' or 'platformid' (etc), then use the correct check*
>> methods on them, and then connect to an element of that correct type.
We have used this approach on some areas of TL, to discover that is not a good approach, when the caller knows what is the type of item he is working on.

>> I do not plan to work further on this until I know the full picture of how
>> test execution is planned.
Hope other user will be willing to donate his time and contribute, no matter future direction of test execution will be.
(0011370)
kinow (reporter)
2010-09-15 16:03

Hi everybody. I would like to try to help with this issue. I am reading the source code, and some contributions that were submitted here in Mantis previously but worked only with execution.

Francisco, how's it going? I'd talked with you about TestLink Hudson plug-in. Thanks again for your support. Would you help me in this issue? Please (-:

I read this issue history. However after taking a look at the database model, I see two different approaches. In the first we implement something like: uploadAttachment($args) where args has fk_id, fk_table, attachment description, title and the $uploaddata (base64 encoded string). In the second approach we could implement different methods for each table, for e.g.: uploadExecutionAttachment(), uploadTestCaseAttachment(), and so it goes.

Which approach do you think we should use in the API?

Cheers,
Bruno
(0011371)
kinow (reporter)
2010-09-15 16:04

BTW, if anybody see a different way of implementing the attachment upload function in the API, feel free to add suggestions (-:

-B
(0011372)
fman (administrator)
2010-09-15 16:27

go for:
>>uploadExecutionAttachment(), uploadTestCaseAttachment(), and so it goes.
but creating a wrapper around uploadAttachment($args).

hope explanation was clear

let me know if you are going to do this and if you want to contribute with TL, in order to plan reviews and future access to CVS
(0011373)
kinow (reporter)
2010-09-15 16:42

I got it, implement uploadAttachment and then methods that wrap the call to this method. Great idea. Should we let uploadAttachment available too? Or only the uploadExecutionAttachment, uploadTestCaseAttachment, etc?

I'm going to do this and contribute with TL. I'll add a patch to this issue as soon as I'm finished.

-B
(0011374)
fman (administrator)
2010-09-15 17:02

1. please attach full code no patch ( I prefer to do code review on full code)
2.
>> I got it, implement uploadAttachment and then methods that wrap the call to
>> this method. Great idea. Should we let uploadAttachment available too? Or only >> the uploadExecutionAttachment, uploadTestCaseAttachment, etc?
expose also uploadAttachment(); this way people can use it without waiting for the 'verbose' method.
(0011381)
kinow (reporter)
2010-09-15 23:04

Got it. Will get back here when I have some work done. Thanks Francisco.
(0011401)
kinow (reporter)
2010-09-17 19:09
edited on: 2010-09-17 22:30

Hello,

could somebody please review my code? It is been a long time I don't code in PHP, so I may be a little roasty in PHP now. It took a little while to upload my code because I am not used to the TestLink project yet. I didn't use the localization feature in the strings. Could somebody fix it (or show me how to make it (-:)? I also didn't know which role would have access right, so I used mgt_view_tc. Is it right? I tried keep the project standards, phpdoc comments and variable and api variables name format, however some thing may have passed.

I also uploaded the Java unit tests project that I used to test the upload feature. It uses maven and TestNG.

I didn't test a file that exceeds the maximum attachment size though. Sorry.

But I did test the parameters combination (missing content, missing foreign key, etc), enabling DataBase storage instead of FileSystem and GZip compression enabled.

I put a few TODO marks where I had doubts. I added an authenticate property to the api class to avoid double authentication. I don't know if it is the best option. What do you guys think about it?

I had to modify tlAttachmentRepository.class.php because it was using move_uploaded_file when TL was configured to store attachments in File System. I added an is_uploaded_file before this call and in case it is a non-uploaded file, I simply use rename.

The attachment content is being interpreted as Base64 encoded.

The implemented methods were:

uploadRequirementSpecificationAttachment
uploadRequirementAttachment
uploadTestProjectAttachment
uploadTestSuiteAttachment
uploadTestCaseAttachment
uploadAttachment

All the above methods just wrap a call to uploadAttachment.

Cheers, -B

(0011402)
fman (administrator)
2010-09-18 06:29

I will review your code

regards

Francisco
(0011407)
fman (administrator)
2010-09-18 09:17
edited on: 2010-09-18 13:41

First things

1. To allow traceability bewteen req and code changes
   a. always add BUGID XXXX file header
   b. function header
   c. near pieces of code changed

2. Also add the developer signature -> email

3. do not use MAGIC CONSTANT -> if node type 1 is testproject, use existent
method to get form a descriptive node type name the node type code
Same apply on comments

4. lenght of code line < 100 chars

5. add new method at end of existent method this make diff the file easier
more to come (may be)

(0011408)
kinow (reporter)
2010-09-18 13:43

Thanks for reviewing it Francisco. I'm sorry for these mistakes, I've just checked TL site and found these instructions in the Developer Guide (great document, by the way). I'm going read it and try to follow the rules in my next contribution (-:

I forgot to add my mail, if you need it it's brunodepaulak at yahoo com br.

And about 4, I was trying to keep cyclomatic complexity and code lines short, however I missed some of it in the uploadAttachment method I guess. My bad (-: I'll pay more attention to this rule next time.

Thanks again for reviewing it.
Bruno
(0011409)
fman (administrator)
2010-09-18 14:50

Bruno:
1. thanks for you contribution
2. thanks for accepting the reviews

I've just committed code with some minor changes (you can give a look if you want)
I've added just one sample client written on PHP

I will consider this resolved ( I kwon I need to do more tests using PHP simple clients). I would apreciate if you can get last code and run yor automated test.

have a nice week end
(0011410)
fman (administrator)
2010-09-18 14:50

resolved with contributed code
(0011759)
fman (administrator)
2010-10-09 08:01

Release 1.9 RC1

- Issue History
Date Modified Username Field Change
2008-11-19 22:13 partymungo New Issue
2008-11-19 22:13 partymungo Browser => Firefox 2.0.0.17
2008-11-20 04:59 azl Status new => assigned
2008-11-20 04:59 azl Assigned To => azl
2008-11-20 05:01 azl Note Added: 0004666
2008-11-20 15:48 partymungo Note Added: 0004671
2010-04-05 14:58 fman Note Added: 0009623
2010-04-05 17:57 austvik Note Added: 0009625
2010-04-06 01:00 fman Note Added: 0009628
2010-05-09 01:18 austvik Note Added: 0009962
2010-05-09 16:40 fman Note Added: 0009963
2010-05-09 16:41 fman Assigned To azl =>
2010-09-15 16:03 kinow Note Added: 0011370
2010-09-15 16:04 kinow Note Added: 0011371
2010-09-15 16:27 fman Note Added: 0011372
2010-09-15 16:42 kinow Note Added: 0011373
2010-09-15 17:02 fman Note Added: 0011374
2010-09-15 23:04 kinow Note Added: 0011381
2010-09-17 18:54 kinow File Added: xmlrpc.class.php
2010-09-17 18:54 kinow File Added: tlAttachmentRepository.class.php
2010-09-17 18:54 kinow File Added: testlinkunittests.zip
2010-09-17 19:09 kinow Note Added: 0011401
2010-09-17 22:28 kinow Note Edited: 0011401 View Revisions
2010-09-17 22:30 kinow Note Edited: 0011401 View Revisions
2010-09-18 06:29 fman Note Added: 0011402
2010-09-18 06:29 fman Assigned To => fman
2010-09-18 09:17 fman Note Added: 0011407
2010-09-18 09:25 fman Note Edited: 0011407 View Revisions
2010-09-18 13:22 fman Note Edited: 0011407 View Revisions
2010-09-18 13:41 fman Note Edited: 0011407 View Revisions
2010-09-18 13:43 kinow Note Added: 0011408
2010-09-18 14:50 fman Note Added: 0011409
2010-09-18 14:50 fman Note Added: 0011410
2010-09-18 14:50 fman Status assigned => resolved
2010-09-18 14:50 fman Fixed in Version => 1.9 RC 1
2010-09-18 14:50 fman Resolution open => fixed
2010-10-09 08:01 fman Note Added: 0011759
2010-10-09 08:01 fman Status resolved => closed
2013-04-25 17:30 fman Category TL API => XMLRPC API
2013-04-25 17:30 fman Category XMLRPC API => API - XMLRPC



Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker