Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/client_internals/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::client::Result;
///#
///# fn example_function() {
/// let jenkins = JenkinsBuilder::new("http://localhost:8080")
/// .with_user("user", Some("password"))
/// .with_user("user", Some("password_or_token"))
/// .build()
/// .unwrap();
///# }
Expand All @@ -23,6 +23,7 @@ use crate::client::Result;
pub struct JenkinsBuilder {
url: String,
user: Option<User>,
allow_insecure_ssl_connection: bool,
csrf_enabled: bool,
depth: u8,
}
Expand All @@ -39,6 +40,7 @@ impl JenkinsBuilder {
}
},
user: None,
allow_insecure_ssl_connection: false,
csrf_enabled: true,
depth: 1,
}
Expand All @@ -56,7 +58,9 @@ impl JenkinsBuilder {

Ok(Jenkins {
url: self.url,
client: Client::builder().build()?,
client: Client::builder()
.danger_accept_invalid_certs(self.allow_insecure_ssl_connection)
.build()?,
user: self.user,
csrf_enabled: self.csrf_enabled,
depth: self.depth,
Expand All @@ -72,6 +76,12 @@ impl JenkinsBuilder {
self
}

/// Allow connections with invalid or self-signed certificates
pub fn allow_insecure_ssl(mut self) -> Self {
self.allow_insecure_ssl_connection = true;
self
}

/// Disable CSRF in crumbs used for post queries
pub fn disable_csrf(mut self) -> Self {
self.csrf_enabled = false;
Expand Down Expand Up @@ -108,6 +118,14 @@ mod tests {
assert_eq!(jenkins_client.csrf_enabled, true);
}

#[test]
fn create_builder_allowing_insecure_tls() {
let jenkins_client = crate::JenkinsBuilder::new(JENKINS_URL).allow_insecure_ssl();
assert_eq!(jenkins_client.url, JENKINS_URL);
assert_eq!(jenkins_client.user, None);
assert_eq!(jenkins_client.allow_insecure_ssl_connection, true);
}

#[test]
fn disable_csrf() {
let jenkins_client = crate::JenkinsBuilder::new(JENKINS_URL).disable_csrf();
Expand Down
2 changes: 1 addition & 1 deletion src/job/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ macro_rules! job_buildable_with_common_fields_and_impl {
)*)*
private_fields {
/// Properties of the job
property: Vec<CommonProperty>,
_property: Vec<CommonProperty>,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/scm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod browser;
pub use self::browser::*;

/// SCM merge options
#[allow(dead_code)]
#[derive(Default, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct MergeOptions {
Expand Down