1 package org.apache.maven.wagon.providers.http;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.http.auth.AuthScope;
23 import org.apache.maven.wagon.shared.http.BasicAuthScope;
24 import org.junit.Assert;
25 import org.junit.Test;
26
27 public class BasicAuthScopeTest
28 {
29
30
31
32
33
34 @Test
35 public void testGetScopeNothingOverridden()
36 {
37 BasicAuthScope scope = new BasicAuthScope();
38
39 AuthScope authScope = scope.getScope( "original.host.com", 3456 );
40 Assert.assertEquals( "original.host.com", authScope.getHost() );
41 Assert.assertEquals( 3456, authScope.getPort() );
42 Assert.assertEquals( AuthScope.ANY_REALM, authScope.getRealm() );
43 }
44
45
46
47
48 @Test
49 public void testGetScopeAllOverridden()
50 {
51 BasicAuthScope scope = new BasicAuthScope();
52 scope.setHost( "override.host.com" );
53 scope.setPort( "1234" );
54 scope.setRealm( "override-realm" );
55 AuthScope authScope = scope.getScope( "original.host.com", 3456 );
56 Assert.assertEquals( "override.host.com", authScope.getHost() );
57 Assert.assertEquals( 1234, authScope.getPort() );
58 Assert.assertEquals( "override-realm", authScope.getRealm() );
59 }
60
61
62
63
64 @Test
65 public void testGetScopeAllAny()
66 {
67 BasicAuthScope scope = new BasicAuthScope();
68 scope.setHost( "ANY" );
69 scope.setPort( "ANY" );
70 scope.setRealm( "ANY" );
71 AuthScope authScope = scope.getScope( "original.host.com", 3456 );
72 Assert.assertEquals( AuthScope.ANY_HOST, authScope.getHost() );
73 Assert.assertEquals( AuthScope.ANY_PORT, authScope.getPort() );
74 Assert.assertEquals( AuthScope.ANY_REALM, authScope.getRealm() );
75 }
76
77
78
79
80 @Test
81 public void testGetScopeRealmOverridden()
82 {
83 BasicAuthScope scope = new BasicAuthScope();
84 scope.setRealm( "override-realm" );
85 AuthScope authScope = scope.getScope( "original.host.com", 3456 );
86 Assert.assertEquals( "original.host.com", authScope.getHost() );
87 Assert.assertEquals( 3456, authScope.getPort() );
88 Assert.assertEquals( "override-realm", authScope.getRealm() );
89 }
90
91
92
93
94 @Test
95 public void testGetScopeOriginalPortIsNegativeOne()
96 {
97 BasicAuthScope scope = new BasicAuthScope();
98 AuthScope authScope = scope.getScope( "original.host.com", -1 );
99 Assert.assertEquals( AuthScope.ANY_PORT, authScope.getPort() );
100 }
101 }