[JAVA-3782] Use the platform-specific line separator in Authorization header Created: 09/Jul/20  Updated: 28/Oct/23  Resolved: 15/Jul/20

Status: Closed
Project: Java Driver
Component/s: Security
Affects Version/s: None
Fix Version/s: 4.1.0

Type: Improvement Priority: Major - P3
Reporter: Farès Hassak Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Attachments: PNG File 2020-07-09 22_25_39-Microsoft Store.png     PNG File 2020-07-10 00_11_39-Test results - Class com.mongodb.internal.connection.AuthorizationHeaderTest.png     PNG File 2020-07-10 00_28_57-Test results - Class com.mongodb.internal.connection.AuthorizationHeaderTest.png     PNG File 2020-07-15 00_30_44-mongo-java-driver – AuthorizationHeaderTest.java [mongo-java-driver.driver-core..png    

 Description   

Hello,

I try to build the java driver with Windows.

Failed Test due to line separator  :

  •  AuthorizationHeaderTest.testCreateCanonicalRequest

org.junit.ComparisonFailure: expected:<...coded; charset=utf-8[
host:iam.amazonaws.com
x-amz-date:20150830T123600Z]
 
content-type;host;...> but was:<...coded; charset=utf-8[
host:iam.amazonaws.com
x-amz-date:20150830T123600Z
]
 
content-type;host;...>
	at org.junit.Assert.assertEquals(Assert.java:115)
	at org.junit.Assert.assertEquals(Assert.java:144)
	at com.mongodb.internal.connection.AuthorizationHeaderTest.testCreateCanonicalRequest(AuthorizationHeaderTest.java:138)

* AuthorizationHeaderTest.testGetCanonicalHeaders

 

org.junit.ComparisonFailure: expected:<...coded; charset=utf-8[
host:iam.amazonaws.com
my-header1:a b c
my-header2:"a b c"
x-amz-date:20150830T123600Z]
> but was:<...coded; charset=utf-8[
host:iam.amazonaws.com
my-header1:a b c
my-header2:"a b c"
x-amz-date:20150830T123600Z
]
>
	at org.junit.Assert.assertEquals(Assert.java:115)
	at org.junit.Assert.assertEquals(Assert.java:144)
	at com.mongodb.internal.connection.AuthorizationHeaderTest.testGetCanonicalHeaders(AuthorizationHeaderTest.java:105)

I do a PR to fix this issue.



 Comments   
Comment by Jeffrey Yemin [ 15/Jul/20 ]

Author:

{'name': 'Farès Hassak', 'email': 'fares.hassak@gmail.com', 'username': 'fhassak'}

Message: Use the platform-specific line separator in Authorization header (#555)

JAVA-3782

Co-authored-by: fhassak <fares-externe.hassak@enedis.fr>
Branch: 4.1.x
https://github.com/mongodb/mongo-java-driver/commit/3413d85c6130c85cb6c3e275e4795de88e2a220f

Comment by Githook User [ 15/Jul/20 ]

Author:

{'name': 'Farès Hassak', 'email': 'fares.hassak@gmail.com', 'username': 'fhassak'}

Message: Use the platform-specific line separator in Authorization header (#555)

JAVA-3782

Co-authored-by: fhassak <fares-externe.hassak@enedis.fr>
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/2f275ddcfbe69f2eb5afcce8b500d12e30f6d2ce

Comment by Farès Hassak [ 14/Jul/20 ]

Hello,

My first commit is wrong and i revert it.
I do a second commit after investigating further.
AWS use Unix-style line endings (LF).
So the new line must be '\n` and do not be platform-specific.

(The title of this ticket is wrong)

Comment by Ross Lawley [ 10/Jul/20 ]

Thanks fares.hassak@gmail.com for the ticket and the PR.

This will be reviewed and scheduled in the near future.

Generated at Thu Feb 08 09:00:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.