Skip to content
This repository was archived by the owner on Jun 9, 2021. It is now read-only.

Commit ec83352

Browse files
committed
Adding optional schema to proxy configuration #211
1 parent 34e16b9 commit ec83352

File tree

9 files changed

+129
-66
lines changed

9 files changed

+129
-66
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Changelog of Pull Request Notifier for Bitbucket.
66
### No issue
77
doc
88

9-
[aaab4df796efde4](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/aaab4df796efde4) Tomas Bjerre *2017-03-25 08:01:32*
9+
[34e16b98c5fde82](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/34e16b98c5fde82) Tomas Bjerre *2017-03-25 08:02:02*
1010

1111
## 2.61
1212
### GitHub [#208](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/208) Injection URL does not allow variables

src/main/java/se/bjurr/prnfb/http/UrlInvoker.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public static UrlInvoker urlInvoker() {
8888
private Optional<String> proxyHost = absent();
8989
private Optional<String> proxyPassword = absent();
9090
private Optional<Integer> proxyPort = absent();
91+
private Optional<String> proxySchema = absent();
9192
private Optional<String> proxyUser = absent();
9293
private HttpResponse response;
9394

@@ -134,6 +135,10 @@ public Optional<Integer> getProxyPort() {
134135
return this.proxyPort;
135136
}
136137

138+
public Optional<String> getProxySchema() {
139+
return proxySchema;
140+
}
141+
137142
public Optional<String> getProxyUser() {
138143
return this.proxyUser;
139144
}
@@ -230,6 +235,11 @@ public UrlInvoker withProxyPort(Integer proxyPort) {
230235
return this;
231236
}
232237

238+
public UrlInvoker withProxySchema(Optional<String> proxySchema) {
239+
this.proxySchema = proxySchema;
240+
return this;
241+
}
242+
233243
public UrlInvoker withProxyServer(Optional<String> proxyHost) {
234244
this.proxyHost = proxyHost;
235245
return this;
@@ -314,7 +324,8 @@ HttpClientBuilder configureProxy(HttpClientBuilder builder) {
314324
}
315325

316326
builder.useSystemProperties();
317-
builder.setProxy(new HttpHost(this.proxyHost.get(), this.proxyPort.get()));
327+
builder.setProxy(
328+
new HttpHost(this.proxyHost.get(), this.proxyPort.get(), this.proxySchema.orNull()));
318329
builder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
319330
return builder;
320331
}

src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public NotificationResponse notify(
262262
urlInvoker //
263263
.withProxyServer(notification.getProxyServer()) //
264264
.withProxyPort(notification.getProxyPort()) //
265+
.withProxySchema(notification.getProxySchema()) //
265266
.withProxyUser(notification.getProxyUser()) //
266267
.withProxyPassword(notification.getProxyPassword()) //
267268
.shouldAcceptAnyCertificate(shouldAcceptAnyCertificate));

src/main/java/se/bjurr/prnfb/presentation/dto/NotificationDTO.java

Lines changed: 82 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class NotificationDTO implements Comparable<NotificationDTO>, Restricted
3131
private String proxyPassword;
3232
private Integer proxyPort;
3333
private String proxyServer;
34+
private String proxySchema;
3435
private String proxyUser;
3536
private String repositorySlug;
3637
private TRIGGER_IF_MERGE triggerIfCanMerge;
@@ -62,143 +63,153 @@ public boolean equals(Object obj) {
6263
return false;
6364
}
6465
NotificationDTO other = (NotificationDTO) obj;
65-
if (this.filterRegexp == null) {
66+
if (filterRegexp == null) {
6667
if (other.filterRegexp != null) {
6768
return false;
6869
}
69-
} else if (!this.filterRegexp.equals(other.filterRegexp)) {
70+
} else if (!filterRegexp.equals(other.filterRegexp)) {
7071
return false;
7172
}
72-
if (this.filterString == null) {
73+
if (filterString == null) {
7374
if (other.filterString != null) {
7475
return false;
7576
}
76-
} else if (!this.filterString.equals(other.filterString)) {
77+
} else if (!filterString.equals(other.filterString)) {
7778
return false;
7879
}
79-
if (this.headers == null) {
80+
if (headers == null) {
8081
if (other.headers != null) {
8182
return false;
8283
}
83-
} else if (!this.headers.equals(other.headers)) {
84+
} else if (!headers.equals(other.headers)) {
8485
return false;
8586
}
86-
if (this.injectionUrl == null) {
87+
if (injectionUrl == null) {
8788
if (other.injectionUrl != null) {
8889
return false;
8990
}
90-
} else if (!this.injectionUrl.equals(other.injectionUrl)) {
91+
} else if (!injectionUrl.equals(other.injectionUrl)) {
9192
return false;
9293
}
93-
if (this.injectionUrlRegexp == null) {
94+
if (injectionUrlRegexp == null) {
9495
if (other.injectionUrlRegexp != null) {
9596
return false;
9697
}
97-
} else if (!this.injectionUrlRegexp.equals(other.injectionUrlRegexp)) {
98+
} else if (!injectionUrlRegexp.equals(other.injectionUrlRegexp)) {
9899
return false;
99100
}
100-
if (this.method != other.method) {
101+
if (method != other.method) {
101102
return false;
102103
}
103-
if (this.name == null) {
104+
if (name == null) {
104105
if (other.name != null) {
105106
return false;
106107
}
107-
} else if (!this.name.equals(other.name)) {
108+
} else if (!name.equals(other.name)) {
108109
return false;
109110
}
110-
if (this.password == null) {
111+
if (password == null) {
111112
if (other.password != null) {
112113
return false;
113114
}
114-
} else if (!this.password.equals(other.password)) {
115+
} else if (!password.equals(other.password)) {
115116
return false;
116117
}
117-
if (this.postContent == null) {
118+
if (postContent == null) {
118119
if (other.postContent != null) {
119120
return false;
120121
}
121-
} else if (!this.postContent.equals(other.postContent)) {
122+
} else if (!postContent.equals(other.postContent)) {
122123
return false;
123124
}
124-
if (this.projectKey == null) {
125+
if (postContentEncoding != other.postContentEncoding) {
126+
return false;
127+
}
128+
if (projectKey == null) {
125129
if (other.projectKey != null) {
126130
return false;
127131
}
128-
} else if (!this.projectKey.equals(other.projectKey)) {
132+
} else if (!projectKey.equals(other.projectKey)) {
129133
return false;
130134
}
131-
if (this.proxyPassword == null) {
135+
if (proxyPassword == null) {
132136
if (other.proxyPassword != null) {
133137
return false;
134138
}
135-
} else if (!this.proxyPassword.equals(other.proxyPassword)) {
139+
} else if (!proxyPassword.equals(other.proxyPassword)) {
136140
return false;
137141
}
138-
if (this.proxyPort == null) {
142+
if (proxyPort == null) {
139143
if (other.proxyPort != null) {
140144
return false;
141145
}
142-
} else if (!this.proxyPort.equals(other.proxyPort)) {
146+
} else if (!proxyPort.equals(other.proxyPort)) {
147+
return false;
148+
}
149+
if (proxySchema == null) {
150+
if (other.proxySchema != null) {
151+
return false;
152+
}
153+
} else if (!proxySchema.equals(other.proxySchema)) {
143154
return false;
144155
}
145-
if (this.proxyServer == null) {
156+
if (proxyServer == null) {
146157
if (other.proxyServer != null) {
147158
return false;
148159
}
149-
} else if (!this.proxyServer.equals(other.proxyServer)) {
160+
} else if (!proxyServer.equals(other.proxyServer)) {
150161
return false;
151162
}
152-
if (this.proxyUser == null) {
163+
if (proxyUser == null) {
153164
if (other.proxyUser != null) {
154165
return false;
155166
}
156-
} else if (!this.proxyUser.equals(other.proxyUser)) {
167+
} else if (!proxyUser.equals(other.proxyUser)) {
157168
return false;
158169
}
159-
if (this.repositorySlug == null) {
170+
if (repositorySlug == null) {
160171
if (other.repositorySlug != null) {
161172
return false;
162173
}
163-
} else if (!this.repositorySlug.equals(other.repositorySlug)) {
174+
} else if (!repositorySlug.equals(other.repositorySlug)) {
164175
return false;
165176
}
166-
if (this.triggerIfCanMerge != other.triggerIfCanMerge) {
177+
if (triggerIfCanMerge != other.triggerIfCanMerge) {
167178
return false;
168179
}
169-
if (this.triggerIgnoreStateList == null) {
180+
if (triggerIgnoreStateList == null) {
170181
if (other.triggerIgnoreStateList != null) {
171182
return false;
172183
}
173-
} else if (!this.triggerIgnoreStateList.equals(other.triggerIgnoreStateList)) {
184+
} else if (!triggerIgnoreStateList.equals(other.triggerIgnoreStateList)) {
174185
return false;
175186
}
176-
if (this.triggers == null) {
187+
if (triggers == null) {
177188
if (other.triggers != null) {
178189
return false;
179190
}
180-
} else if (!this.triggers.equals(other.triggers)) {
191+
} else if (!triggers.equals(other.triggers)) {
181192
return false;
182193
}
183-
if (this.url == null) {
194+
if (url == null) {
184195
if (other.url != null) {
185196
return false;
186197
}
187-
} else if (!this.url.equals(other.url)) {
198+
} else if (!url.equals(other.url)) {
188199
return false;
189200
}
190-
if (this.user == null) {
201+
if (user == null) {
191202
if (other.user != null) {
192203
return false;
193204
}
194-
} else if (!this.user.equals(other.user)) {
205+
} else if (!user.equals(other.user)) {
195206
return false;
196207
}
197-
if (this.uuid == null) {
208+
if (uuid == null) {
198209
if (other.uuid != null) {
199210
return false;
200211
}
201-
} else if (!this.uuid.equals(other.uuid)) {
212+
} else if (!uuid.equals(other.uuid)) {
202213
return false;
203214
}
204215
return true;
@@ -294,31 +305,30 @@ public UUID getUuid() {
294305
public int hashCode() {
295306
final int prime = 31;
296307
int result = 1;
297-
result = prime * result + (this.filterRegexp == null ? 0 : this.filterRegexp.hashCode());
298-
result = prime * result + (this.filterString == null ? 0 : this.filterString.hashCode());
299-
result = prime * result + (this.headers == null ? 0 : this.headers.hashCode());
300-
result = prime * result + (this.injectionUrl == null ? 0 : this.injectionUrl.hashCode());
308+
result = prime * result + (filterRegexp == null ? 0 : filterRegexp.hashCode());
309+
result = prime * result + (filterString == null ? 0 : filterString.hashCode());
310+
result = prime * result + (headers == null ? 0 : headers.hashCode());
311+
result = prime * result + (injectionUrl == null ? 0 : injectionUrl.hashCode());
312+
result = prime * result + (injectionUrlRegexp == null ? 0 : injectionUrlRegexp.hashCode());
313+
result = prime * result + (method == null ? 0 : method.hashCode());
314+
result = prime * result + (name == null ? 0 : name.hashCode());
315+
result = prime * result + (password == null ? 0 : password.hashCode());
316+
result = prime * result + (postContent == null ? 0 : postContent.hashCode());
317+
result = prime * result + (postContentEncoding == null ? 0 : postContentEncoding.hashCode());
318+
result = prime * result + (projectKey == null ? 0 : projectKey.hashCode());
319+
result = prime * result + (proxyPassword == null ? 0 : proxyPassword.hashCode());
320+
result = prime * result + (proxyPort == null ? 0 : proxyPort.hashCode());
321+
result = prime * result + (proxySchema == null ? 0 : proxySchema.hashCode());
322+
result = prime * result + (proxyServer == null ? 0 : proxyServer.hashCode());
323+
result = prime * result + (proxyUser == null ? 0 : proxyUser.hashCode());
324+
result = prime * result + (repositorySlug == null ? 0 : repositorySlug.hashCode());
325+
result = prime * result + (triggerIfCanMerge == null ? 0 : triggerIfCanMerge.hashCode());
301326
result =
302-
prime * result + (this.injectionUrlRegexp == null ? 0 : this.injectionUrlRegexp.hashCode());
303-
result = prime * result + (this.method == null ? 0 : this.method.hashCode());
304-
result = prime * result + (this.name == null ? 0 : this.name.hashCode());
305-
result = prime * result + (this.password == null ? 0 : this.password.hashCode());
306-
result = prime * result + (this.postContent == null ? 0 : this.postContent.hashCode());
307-
result = prime * result + (this.projectKey == null ? 0 : this.projectKey.hashCode());
308-
result = prime * result + (this.proxyPassword == null ? 0 : this.proxyPassword.hashCode());
309-
result = prime * result + (this.proxyPort == null ? 0 : this.proxyPort.hashCode());
310-
result = prime * result + (this.proxyServer == null ? 0 : this.proxyServer.hashCode());
311-
result = prime * result + (this.proxyUser == null ? 0 : this.proxyUser.hashCode());
312-
result = prime * result + (this.repositorySlug == null ? 0 : this.repositorySlug.hashCode());
313-
result =
314-
prime * result + (this.triggerIfCanMerge == null ? 0 : this.triggerIfCanMerge.hashCode());
315-
result =
316-
prime * result
317-
+ (this.triggerIgnoreStateList == null ? 0 : this.triggerIgnoreStateList.hashCode());
318-
result = prime * result + (this.triggers == null ? 0 : this.triggers.hashCode());
319-
result = prime * result + (this.url == null ? 0 : this.url.hashCode());
320-
result = prime * result + (this.user == null ? 0 : this.user.hashCode());
321-
result = prime * result + (this.uuid == null ? 0 : this.uuid.hashCode());
327+
prime * result + (triggerIgnoreStateList == null ? 0 : triggerIgnoreStateList.hashCode());
328+
result = prime * result + (triggers == null ? 0 : triggers.hashCode());
329+
result = prime * result + (url == null ? 0 : url.hashCode());
330+
result = prime * result + (user == null ? 0 : user.hashCode());
331+
result = prime * result + (uuid == null ? 0 : uuid.hashCode());
322332
return result;
323333
}
324334

@@ -409,4 +419,12 @@ public void setUuid(UUID uuid) {
409419
public ENCODE_FOR getPostContentEncoding() {
410420
return postContentEncoding;
411421
}
422+
423+
public void setProxySchema(String proxySchema) {
424+
this.proxySchema = proxySchema;
425+
}
426+
427+
public String getProxySchema() {
428+
return proxySchema;
429+
}
412430
}

src/main/java/se/bjurr/prnfb/service/PrnfbVariable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public String resolve(
128128
.withMethod(GET) //
129129
.withProxyServer(prnfbNotification.getProxyServer()) //
130130
.withProxyPort(prnfbNotification.getProxyPort()) //
131+
.withProxySchema(prnfbNotification.getProxySchema()) //
131132
.withProxyUser(prnfbNotification.getProxyUser()) //
132133
.withProxyPassword(prnfbNotification.getProxyPassword()) //
133134
.appendBasicAuth(prnfbNotification) //

src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ public class PrnfbNotification implements HasUuid, Restricted {
4747
private final String user;
4848
private final UUID uuid;
4949
private final ENCODE_FOR postContentEncoding;
50+
private final String proxySchema;
5051

5152
public PrnfbNotification(PrnfbNotificationBuilder builder) throws ValidationException {
5253
this.uuid = firstNonNull(builder.getUUID(), randomUUID());
5354
this.proxyUser = emptyToNull(nullToEmpty(builder.getProxyUser()).trim());
5455
this.proxyPassword = emptyToNull(nullToEmpty(builder.getProxyPassword()).trim());
5556
this.proxyServer = emptyToNull(nullToEmpty(builder.getProxyServer()).trim());
57+
this.proxySchema = emptyToNull(nullToEmpty(builder.getProxySchema()).trim());
5658
this.proxyPort = builder.getProxyPort();
5759
this.headers = checkNotNull(builder.getHeaders());
5860
this.postContent = emptyToNull(nullToEmpty(builder.getPostContent()).trim());
@@ -299,6 +301,10 @@ public Integer getProxyPort() {
299301
return this.proxyPort;
300302
}
301303

304+
public Optional<String> getProxySchema() {
305+
return fromNullable(this.proxySchema);
306+
}
307+
302308
public Optional<String> getProxyServer() {
303309
return fromNullable(this.proxyServer);
304310
}

src/main/java/se/bjurr/prnfb/settings/PrnfbNotificationBuilder.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(PrnfbNotificatio
3737
b.proxyUser = from.getProxyUser().orNull();
3838
b.proxyPassword = from.getProxyPassword().orNull();
3939
b.proxyServer = from.getProxyServer().orNull();
40+
b.proxySchema = from.getProxySchema().orNull();
4041
b.proxyPort = from.getProxyPort();
4142
b.name = from.getName();
4243
b.injectionUrl = from.getInjectionUrl().orNull();
@@ -68,6 +69,7 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(PrnfbNotificatio
6869
private String user;
6970
private UUID uuid;
7071
private ENCODE_FOR postContentEncoding;
72+
private String proxySchema;
7173

7274
private PrnfbNotificationBuilder() {
7375
this.uuid = randomUUID();
@@ -133,6 +135,10 @@ public String getProxyServer() {
133135
return this.proxyServer;
134136
}
135137

138+
public String getProxySchema() {
139+
return proxySchema;
140+
}
141+
136142
public String getProxyUser() {
137143
return this.proxyUser;
138144
}
@@ -294,4 +300,9 @@ public PrnfbNotificationBuilder withUuid(UUID uuid) {
294300
this.uuid = uuid;
295301
return this;
296302
}
303+
304+
public PrnfbNotificationBuilder withProxySchema(String proxySchema) {
305+
this.proxySchema = proxySchema;
306+
return this;
307+
}
297308
}

0 commit comments

Comments
 (0)