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

Commit

Permalink
Adding optional schema to proxy configuration #211
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Apr 5, 2017
1 parent 34e16b9 commit ec83352
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 66 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changelog of Pull Request Notifier for Bitbucket.
### No issue
doc

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

## 2.61
### GitHub [#208](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/208) Injection URL does not allow variables
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/se/bjurr/prnfb/http/UrlInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public static UrlInvoker urlInvoker() {
private Optional<String> proxyHost = absent();
private Optional<String> proxyPassword = absent();
private Optional<Integer> proxyPort = absent();
private Optional<String> proxySchema = absent();
private Optional<String> proxyUser = absent();
private HttpResponse response;

Expand Down Expand Up @@ -134,6 +135,10 @@ public Optional<Integer> getProxyPort() {
return this.proxyPort;
}

public Optional<String> getProxySchema() {
return proxySchema;
}

public Optional<String> getProxyUser() {
return this.proxyUser;
}
Expand Down Expand Up @@ -230,6 +235,11 @@ public UrlInvoker withProxyPort(Integer proxyPort) {
return this;
}

public UrlInvoker withProxySchema(Optional<String> proxySchema) {
this.proxySchema = proxySchema;
return this;
}

public UrlInvoker withProxyServer(Optional<String> proxyHost) {
this.proxyHost = proxyHost;
return this;
Expand Down Expand Up @@ -314,7 +324,8 @@ HttpClientBuilder configureProxy(HttpClientBuilder builder) {
}

builder.useSystemProperties();
builder.setProxy(new HttpHost(this.proxyHost.get(), this.proxyPort.get()));
builder.setProxy(
new HttpHost(this.proxyHost.get(), this.proxyPort.get(), this.proxySchema.orNull()));
builder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public NotificationResponse notify(
urlInvoker //
.withProxyServer(notification.getProxyServer()) //
.withProxyPort(notification.getProxyPort()) //
.withProxySchema(notification.getProxySchema()) //
.withProxyUser(notification.getProxyUser()) //
.withProxyPassword(notification.getProxyPassword()) //
.shouldAcceptAnyCertificate(shouldAcceptAnyCertificate));
Expand Down
146 changes: 82 additions & 64 deletions src/main/java/se/bjurr/prnfb/presentation/dto/NotificationDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class NotificationDTO implements Comparable<NotificationDTO>, Restricted
private String proxyPassword;
private Integer proxyPort;
private String proxyServer;
private String proxySchema;
private String proxyUser;
private String repositorySlug;
private TRIGGER_IF_MERGE triggerIfCanMerge;
Expand Down Expand Up @@ -62,143 +63,153 @@ public boolean equals(Object obj) {
return false;
}
NotificationDTO other = (NotificationDTO) obj;
if (this.filterRegexp == null) {
if (filterRegexp == null) {
if (other.filterRegexp != null) {
return false;
}
} else if (!this.filterRegexp.equals(other.filterRegexp)) {
} else if (!filterRegexp.equals(other.filterRegexp)) {
return false;
}
if (this.filterString == null) {
if (filterString == null) {
if (other.filterString != null) {
return false;
}
} else if (!this.filterString.equals(other.filterString)) {
} else if (!filterString.equals(other.filterString)) {
return false;
}
if (this.headers == null) {
if (headers == null) {
if (other.headers != null) {
return false;
}
} else if (!this.headers.equals(other.headers)) {
} else if (!headers.equals(other.headers)) {
return false;
}
if (this.injectionUrl == null) {
if (injectionUrl == null) {
if (other.injectionUrl != null) {
return false;
}
} else if (!this.injectionUrl.equals(other.injectionUrl)) {
} else if (!injectionUrl.equals(other.injectionUrl)) {
return false;
}
if (this.injectionUrlRegexp == null) {
if (injectionUrlRegexp == null) {
if (other.injectionUrlRegexp != null) {
return false;
}
} else if (!this.injectionUrlRegexp.equals(other.injectionUrlRegexp)) {
} else if (!injectionUrlRegexp.equals(other.injectionUrlRegexp)) {
return false;
}
if (this.method != other.method) {
if (method != other.method) {
return false;
}
if (this.name == null) {
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!this.name.equals(other.name)) {
} else if (!name.equals(other.name)) {
return false;
}
if (this.password == null) {
if (password == null) {
if (other.password != null) {
return false;
}
} else if (!this.password.equals(other.password)) {
} else if (!password.equals(other.password)) {
return false;
}
if (this.postContent == null) {
if (postContent == null) {
if (other.postContent != null) {
return false;
}
} else if (!this.postContent.equals(other.postContent)) {
} else if (!postContent.equals(other.postContent)) {
return false;
}
if (this.projectKey == null) {
if (postContentEncoding != other.postContentEncoding) {
return false;
}
if (projectKey == null) {
if (other.projectKey != null) {
return false;
}
} else if (!this.projectKey.equals(other.projectKey)) {
} else if (!projectKey.equals(other.projectKey)) {
return false;
}
if (this.proxyPassword == null) {
if (proxyPassword == null) {
if (other.proxyPassword != null) {
return false;
}
} else if (!this.proxyPassword.equals(other.proxyPassword)) {
} else if (!proxyPassword.equals(other.proxyPassword)) {
return false;
}
if (this.proxyPort == null) {
if (proxyPort == null) {
if (other.proxyPort != null) {
return false;
}
} else if (!this.proxyPort.equals(other.proxyPort)) {
} else if (!proxyPort.equals(other.proxyPort)) {
return false;
}
if (proxySchema == null) {
if (other.proxySchema != null) {
return false;
}
} else if (!proxySchema.equals(other.proxySchema)) {
return false;
}
if (this.proxyServer == null) {
if (proxyServer == null) {
if (other.proxyServer != null) {
return false;
}
} else if (!this.proxyServer.equals(other.proxyServer)) {
} else if (!proxyServer.equals(other.proxyServer)) {
return false;
}
if (this.proxyUser == null) {
if (proxyUser == null) {
if (other.proxyUser != null) {
return false;
}
} else if (!this.proxyUser.equals(other.proxyUser)) {
} else if (!proxyUser.equals(other.proxyUser)) {
return false;
}
if (this.repositorySlug == null) {
if (repositorySlug == null) {
if (other.repositorySlug != null) {
return false;
}
} else if (!this.repositorySlug.equals(other.repositorySlug)) {
} else if (!repositorySlug.equals(other.repositorySlug)) {
return false;
}
if (this.triggerIfCanMerge != other.triggerIfCanMerge) {
if (triggerIfCanMerge != other.triggerIfCanMerge) {
return false;
}
if (this.triggerIgnoreStateList == null) {
if (triggerIgnoreStateList == null) {
if (other.triggerIgnoreStateList != null) {
return false;
}
} else if (!this.triggerIgnoreStateList.equals(other.triggerIgnoreStateList)) {
} else if (!triggerIgnoreStateList.equals(other.triggerIgnoreStateList)) {
return false;
}
if (this.triggers == null) {
if (triggers == null) {
if (other.triggers != null) {
return false;
}
} else if (!this.triggers.equals(other.triggers)) {
} else if (!triggers.equals(other.triggers)) {
return false;
}
if (this.url == null) {
if (url == null) {
if (other.url != null) {
return false;
}
} else if (!this.url.equals(other.url)) {
} else if (!url.equals(other.url)) {
return false;
}
if (this.user == null) {
if (user == null) {
if (other.user != null) {
return false;
}
} else if (!this.user.equals(other.user)) {
} else if (!user.equals(other.user)) {
return false;
}
if (this.uuid == null) {
if (uuid == null) {
if (other.uuid != null) {
return false;
}
} else if (!this.uuid.equals(other.uuid)) {
} else if (!uuid.equals(other.uuid)) {
return false;
}
return true;
Expand Down Expand Up @@ -294,31 +305,30 @@ public UUID getUuid() {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (this.filterRegexp == null ? 0 : this.filterRegexp.hashCode());
result = prime * result + (this.filterString == null ? 0 : this.filterString.hashCode());
result = prime * result + (this.headers == null ? 0 : this.headers.hashCode());
result = prime * result + (this.injectionUrl == null ? 0 : this.injectionUrl.hashCode());
result = prime * result + (filterRegexp == null ? 0 : filterRegexp.hashCode());
result = prime * result + (filterString == null ? 0 : filterString.hashCode());
result = prime * result + (headers == null ? 0 : headers.hashCode());
result = prime * result + (injectionUrl == null ? 0 : injectionUrl.hashCode());
result = prime * result + (injectionUrlRegexp == null ? 0 : injectionUrlRegexp.hashCode());
result = prime * result + (method == null ? 0 : method.hashCode());
result = prime * result + (name == null ? 0 : name.hashCode());
result = prime * result + (password == null ? 0 : password.hashCode());
result = prime * result + (postContent == null ? 0 : postContent.hashCode());
result = prime * result + (postContentEncoding == null ? 0 : postContentEncoding.hashCode());
result = prime * result + (projectKey == null ? 0 : projectKey.hashCode());
result = prime * result + (proxyPassword == null ? 0 : proxyPassword.hashCode());
result = prime * result + (proxyPort == null ? 0 : proxyPort.hashCode());
result = prime * result + (proxySchema == null ? 0 : proxySchema.hashCode());
result = prime * result + (proxyServer == null ? 0 : proxyServer.hashCode());
result = prime * result + (proxyUser == null ? 0 : proxyUser.hashCode());
result = prime * result + (repositorySlug == null ? 0 : repositorySlug.hashCode());
result = prime * result + (triggerIfCanMerge == null ? 0 : triggerIfCanMerge.hashCode());
result =
prime * result + (this.injectionUrlRegexp == null ? 0 : this.injectionUrlRegexp.hashCode());
result = prime * result + (this.method == null ? 0 : this.method.hashCode());
result = prime * result + (this.name == null ? 0 : this.name.hashCode());
result = prime * result + (this.password == null ? 0 : this.password.hashCode());
result = prime * result + (this.postContent == null ? 0 : this.postContent.hashCode());
result = prime * result + (this.projectKey == null ? 0 : this.projectKey.hashCode());
result = prime * result + (this.proxyPassword == null ? 0 : this.proxyPassword.hashCode());
result = prime * result + (this.proxyPort == null ? 0 : this.proxyPort.hashCode());
result = prime * result + (this.proxyServer == null ? 0 : this.proxyServer.hashCode());
result = prime * result + (this.proxyUser == null ? 0 : this.proxyUser.hashCode());
result = prime * result + (this.repositorySlug == null ? 0 : this.repositorySlug.hashCode());
result =
prime * result + (this.triggerIfCanMerge == null ? 0 : this.triggerIfCanMerge.hashCode());
result =
prime * result
+ (this.triggerIgnoreStateList == null ? 0 : this.triggerIgnoreStateList.hashCode());
result = prime * result + (this.triggers == null ? 0 : this.triggers.hashCode());
result = prime * result + (this.url == null ? 0 : this.url.hashCode());
result = prime * result + (this.user == null ? 0 : this.user.hashCode());
result = prime * result + (this.uuid == null ? 0 : this.uuid.hashCode());
prime * result + (triggerIgnoreStateList == null ? 0 : triggerIgnoreStateList.hashCode());
result = prime * result + (triggers == null ? 0 : triggers.hashCode());
result = prime * result + (url == null ? 0 : url.hashCode());
result = prime * result + (user == null ? 0 : user.hashCode());
result = prime * result + (uuid == null ? 0 : uuid.hashCode());
return result;
}

Expand Down Expand Up @@ -409,4 +419,12 @@ public void setUuid(UUID uuid) {
public ENCODE_FOR getPostContentEncoding() {
return postContentEncoding;
}

public void setProxySchema(String proxySchema) {
this.proxySchema = proxySchema;
}

public String getProxySchema() {
return proxySchema;
}
}
1 change: 1 addition & 0 deletions src/main/java/se/bjurr/prnfb/service/PrnfbVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public String resolve(
.withMethod(GET) //
.withProxyServer(prnfbNotification.getProxyServer()) //
.withProxyPort(prnfbNotification.getProxyPort()) //
.withProxySchema(prnfbNotification.getProxySchema()) //
.withProxyUser(prnfbNotification.getProxyUser()) //
.withProxyPassword(prnfbNotification.getProxyPassword()) //
.appendBasicAuth(prnfbNotification) //
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ public class PrnfbNotification implements HasUuid, Restricted {
private final String user;
private final UUID uuid;
private final ENCODE_FOR postContentEncoding;
private final String proxySchema;

public PrnfbNotification(PrnfbNotificationBuilder builder) throws ValidationException {
this.uuid = firstNonNull(builder.getUUID(), randomUUID());
this.proxyUser = emptyToNull(nullToEmpty(builder.getProxyUser()).trim());
this.proxyPassword = emptyToNull(nullToEmpty(builder.getProxyPassword()).trim());
this.proxyServer = emptyToNull(nullToEmpty(builder.getProxyServer()).trim());
this.proxySchema = emptyToNull(nullToEmpty(builder.getProxySchema()).trim());
this.proxyPort = builder.getProxyPort();
this.headers = checkNotNull(builder.getHeaders());
this.postContent = emptyToNull(nullToEmpty(builder.getPostContent()).trim());
Expand Down Expand Up @@ -299,6 +301,10 @@ public Integer getProxyPort() {
return this.proxyPort;
}

public Optional<String> getProxySchema() {
return fromNullable(this.proxySchema);
}

public Optional<String> getProxyServer() {
return fromNullable(this.proxyServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(PrnfbNotificatio
b.proxyUser = from.getProxyUser().orNull();
b.proxyPassword = from.getProxyPassword().orNull();
b.proxyServer = from.getProxyServer().orNull();
b.proxySchema = from.getProxySchema().orNull();
b.proxyPort = from.getProxyPort();
b.name = from.getName();
b.injectionUrl = from.getInjectionUrl().orNull();
Expand Down Expand Up @@ -68,6 +69,7 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(PrnfbNotificatio
private String user;
private UUID uuid;
private ENCODE_FOR postContentEncoding;
private String proxySchema;

private PrnfbNotificationBuilder() {
this.uuid = randomUUID();
Expand Down Expand Up @@ -133,6 +135,10 @@ public String getProxyServer() {
return this.proxyServer;
}

public String getProxySchema() {
return proxySchema;
}

public String getProxyUser() {
return this.proxyUser;
}
Expand Down Expand Up @@ -294,4 +300,9 @@ public PrnfbNotificationBuilder withUuid(UUID uuid) {
this.uuid = uuid;
return this;
}

public PrnfbNotificationBuilder withProxySchema(String proxySchema) {
this.proxySchema = proxySchema;
return this;
}
}
Loading

0 comments on commit ec83352

Please sign in to comment.