File tree 2 files changed +17
-1
lines changed
main/java/io/securecodebox/persistence/defectdojo/http
test/java/io/securecodebox/persistence/defectdojo/http
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 8
8
import lombok .NonNull ;
9
9
import org .apache .http .HttpHost ;
10
10
import org .apache .http .auth .AuthScope ;
11
+ import org .apache .http .auth .Credentials ;
11
12
import org .apache .http .auth .UsernamePasswordCredentials ;
12
13
import org .apache .http .client .CredentialsProvider ;
13
14
import org .apache .http .impl .client .BasicCredentialsProvider ;
@@ -63,7 +64,7 @@ public RestTemplate createRestTemplate() {
63
64
final var credentials = new BasicCredentialsProvider ();
64
65
credentials .setCredentials (
65
66
createAuthScope (),
66
- new UsernamePasswordCredentials ( proxyConfig . getUser (), proxyConfig . getPassword () )
67
+ createCredentials ( )
67
68
);
68
69
69
70
final var builder = HttpClientBuilder .create ();
@@ -83,4 +84,8 @@ public RestTemplate createRestTemplate() {
83
84
AuthScope createAuthScope () {
84
85
return new AuthScope (proxyConfig .getHost (), proxyConfig .getPort ());
85
86
}
87
+
88
+ Credentials createCredentials () {
89
+ return new UsernamePasswordCredentials (proxyConfig .getUser (), proxyConfig .getPassword ());
90
+ }
86
91
}
Original file line number Diff line number Diff line change 7
7
import io .securecodebox .persistence .defectdojo .config .Config ;
8
8
import lombok .NonNull ;
9
9
import org .apache .http .auth .AuthScope ;
10
+ import org .apache .http .auth .Credentials ;
10
11
import org .junit .jupiter .api .Disabled ;
11
12
import org .junit .jupiter .api .Test ;
12
13
import org .springframework .http .HttpHeaders ;
@@ -75,4 +76,14 @@ void createAuthScope() {
75
76
() -> assertThat (result .getPort (), is (proxyConfig .getPort ()))
76
77
);
77
78
}
79
+
80
+ @ Test
81
+ void createCredentials () {
82
+ final var result = sut .createCredentials ();
83
+
84
+ assertAll (
85
+ () -> assertThat (result .getUserPrincipal ().getName (), is (proxyConfig .getUser ())),
86
+ () -> assertThat (result .getPassword (), is (proxyConfig .getPassword ()))
87
+ );
88
+ }
78
89
}
You can’t perform that action at this time.
0 commit comments