File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
main/java/io/securecodebox/persistence/defectdojo/http
test/java/io/securecodebox/persistence/defectdojo/http Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 88import lombok .NonNull ;
99import org .apache .http .HttpHost ;
1010import org .apache .http .auth .AuthScope ;
11+ import org .apache .http .auth .Credentials ;
1112import org .apache .http .auth .UsernamePasswordCredentials ;
1213import org .apache .http .client .CredentialsProvider ;
1314import org .apache .http .impl .client .BasicCredentialsProvider ;
@@ -63,7 +64,7 @@ public RestTemplate createRestTemplate() {
6364 final var credentials = new BasicCredentialsProvider ();
6465 credentials .setCredentials (
6566 createAuthScope (),
66- new UsernamePasswordCredentials ( proxyConfig . getUser (), proxyConfig . getPassword () )
67+ createCredentials ( )
6768 );
6869
6970 final var builder = HttpClientBuilder .create ();
@@ -83,4 +84,8 @@ public RestTemplate createRestTemplate() {
8384 AuthScope createAuthScope () {
8485 return new AuthScope (proxyConfig .getHost (), proxyConfig .getPort ());
8586 }
87+
88+ Credentials createCredentials () {
89+ return new UsernamePasswordCredentials (proxyConfig .getUser (), proxyConfig .getPassword ());
90+ }
8691}
Original file line number Diff line number Diff line change 77import io .securecodebox .persistence .defectdojo .config .Config ;
88import lombok .NonNull ;
99import org .apache .http .auth .AuthScope ;
10+ import org .apache .http .auth .Credentials ;
1011import org .junit .jupiter .api .Disabled ;
1112import org .junit .jupiter .api .Test ;
1213import org .springframework .http .HttpHeaders ;
@@ -75,4 +76,14 @@ void createAuthScope() {
7576 () -> assertThat (result .getPort (), is (proxyConfig .getPort ()))
7677 );
7778 }
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+ }
7889}
You can’t perform that action at this time.
0 commit comments