Bug 61724

Summary: Add __digest function to provide computing of Hashes (SHA-XXX, MDX)
Product: JMeter Reporter: orimarko <orimarko>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: enhancement CC: p.mouawad
Priority: P2 Keywords: PatchAvailable
Version: 3.3   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: patch
Patch with added two functions and tests
Add patch with 2 functions and tests
Add patch with digest function xdocs
Patch with new Digest function and tests
Patch with new Digest function and tests
Add patch with tests digest function

Description orimarko 2017-11-05 12:22:53 UTC
Created attachment 35486 [details]
patch

Add __sha1 and __sha256 functions to JMeter
Comment 1 orimarko 2017-11-05 12:24:08 UTC
Created attachment 35487 [details]
Patch with added two functions and tests

Attached Patch with added two functions and tests
Comment 2 orimarko 2017-11-05 12:49:54 UTC
Created attachment 35488 [details]
Add patch with 2 functions and tests

Add patch with 2 functions and tests
Comment 3 Philippe Mouawad 2017-11-05 14:01:37 UTC
Thank you for your contribution, I have few remarks:

- Why salt is not also there for SHA1 ?
- I think 1 more generic function is enough
- It would be better to have something like __digest(algorithm, string to digest, salt (optional),uppercase (optional defaults to false), varName (optional)). This would allow more generic algorithm addition
- synchronized does not seem to be needed for me
Comment 4 Philippe Mouawad 2017-11-05 14:04:38 UTC
Also:
- patch file should be built from jmeter folder (the one that contains src)
- if possible, documentation functions.xml should be updated, I'll do it if you don't have time
- Apache License 2 Header should be added to java files
Comment 5 orimarko 2017-11-06 05:59:01 UTC
Created attachment 35493 [details]
Add patch with digest function xdocs

Add patch with digest functions and tests plus function xdocs
Comment 6 orimarko 2017-11-06 05:59:57 UTC
Created attachment 35494 [details]
Patch with new Digest function and tests
Comment 7 orimarko 2017-11-06 07:14:46 UTC
Created attachment 35495 [details]
Patch with new Digest function and tests

Patch with new Digest function fixed and tests
Comment 8 Philippe Mouawad 2017-11-07 07:55:38 UTC
Hello,
I am currently merging the patch but I don't see tests .
Can you attach the patch that only contains them ?
Thanks
Comment 9 orimarko 2017-11-07 08:00:55 UTC
Created attachment 35499 [details]
Add patch with tests digest function

Add patch with tests digest function
Comment 10 orimarko 2017-11-07 08:01:17 UTC
Add tests patch
Comment 11 Philippe Mouawad 2017-11-07 08:28:43 UTC
I merged the function with slight modifications:
- Salt is added at end as it seems to be the standard (https://github.com/mozilla/openbadges-backpack/wiki/How-to-hash-&-salt-in-various-languages.)
- Completed documentation and stated that spaces are taken into account
- Added more tests for spaces

Can you review those changes to see if there are issues and to see how to improve your future contributions that I hope will be exist :-) !

Thanks for this great contribution !

For future patches, can you just ensure that you create patch from root of jmeter project.


Author: pmouawad
Date: Tue Nov  7 08:25:42 2017
New Revision: 1814464

URL: http://svn.apache.org/viewvc?rev=1814464&view=rev
Log:
Bug 61724 - Add __digest function to provide computing of Hashes (SHA-XXX, MDX)
Bugzilla Id: 61724

Added:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/DigestEncode.java   (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/functions/AbstractFunction.java
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/functions.xml
Comment 12 orimarko 2017-11-07 09:21:38 UTC
There are 2 errors in jenkins build

[checkstyle] /home/jenkins/jenkins-slave/workspace/JMeter-trunk/trunk/src/core/org/apache/jmeter/functions/AbstractFunction.java:152:1: error: File contains tab characters (this is the first instance).

[checkstyle] /home/jenkins/jenkins-slave/workspace/JMeter-trunk/trunk/src/functions/org/apache/jmeter/functions/DigestEncode.java:0: error: File does not end with a newline.
Comment 13 orimarko 2017-11-07 12:06:37 UTC
Resolved in apache-jmeter-r1814470, build number 6​42​9

Thank you
Comment 14 Philippe Mouawad 2017-11-08 19:47:05 UTC
Author: pmouawad
Date: Wed Nov  8 19:44:02 2017
New Revision: 1814627

URL: http://svn.apache.org/viewvc?rev=1814627&view=rev
Log:
Bug 61724 - Add __digest function to provide computing of Hashes (SHA-XXX, MDX)
Add tests
Bugzilla Id: 61724
Comment 15 Philippe Mouawad 2017-11-13 20:58:30 UTC
Author: pmouawad
Date: Mon Nov 13 20:58:16 2017
New Revision: 1815133

URL: http://svn.apache.org/viewvc?rev=1815133&view=rev
Log:
Bug 61724 - Add __digest function to provide computing of Hashes (SHA-XXX, MDX)
Suffix class with Function
Bugzilla Id: 61724

Added:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/DigestEncodeFunction.java
      - copied, changed from r1814986, jmeter/trunk/src/functions/org/apache/jmeter/functions/DigestEncode.java
Removed:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/DigestEncode.java
Modified:
    jmeter/trunk/test/src/org/apache/jmeter/functions/TestDigestFunction.java
Comment 16 Philippe Mouawad 2017-11-21 13:10:51 UTC
*** Bug 61763 has been marked as a duplicate of this bug. ***