Skip to content

Commit 28f5e9b

Browse files
committed
[AHC-108] Caller-supplied credential encoding of realm is ignored
1 parent cae4488 commit 28f5e9b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/main/java/com/ning/http/client/Realm.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ public RealmBuilder clone(Realm clone) {
436436
setNonce(clone.getNonce());
437437
setPassword(clone.getPassword());
438438
setPrincipal(clone.getPrincipal());
439+
setEnconding(clone.getEncoding());
439440
setQop(clone.getQop());
440441
setScheme(clone.getScheme());
441442
setUri(clone.getUri());
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2010-2011 Sonatype, Inc. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7+
*
8+
* Unless required by applicable law or agreed to in writing,
9+
* software distributed under the Apache License Version 2.0 is distributed on an
10+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12+
*/
13+
package com.ning.http.client;
14+
15+
import com.ning.http.client.Realm.AuthScheme;
16+
import com.ning.http.client.Realm.RealmBuilder;
17+
import org.testng.Assert;
18+
import org.testng.annotations.Test;
19+
20+
public class RealmTest {
21+
@Test(groups = "fast")
22+
public void testClone() {
23+
RealmBuilder builder = new RealmBuilder();
24+
builder.setPrincipal( "user" ).setPassword( "pass" );
25+
builder.setEnconding( "enc" ).setUsePreemptiveAuth( true );
26+
builder.setRealmName( "realm" ).setAlgorithm( "algo" );
27+
builder.setScheme( AuthScheme.BASIC );
28+
Realm orig = builder.build();
29+
30+
Realm clone = new RealmBuilder().clone( orig ).build();
31+
Assert.assertEquals( clone.getPrincipal(), orig.getPrincipal() );
32+
Assert.assertEquals( clone.getPassword(), orig.getPassword() );
33+
Assert.assertEquals( clone.getEncoding(), orig.getEncoding() );
34+
Assert.assertEquals( clone.getUsePreemptiveAuth(), orig.getUsePreemptiveAuth() );
35+
Assert.assertEquals( clone.getRealmName(), orig.getRealmName() );
36+
Assert.assertEquals( clone.getAlgorithm(), orig.getAlgorithm() );
37+
Assert.assertEquals( clone.getAuthScheme(), orig.getAuthScheme() );
38+
}
39+
}

0 commit comments

Comments
 (0)