summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/http/mod.rs6
-rw-r--r--src/main.rs14
2 files changed, 8 insertions, 12 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs
index 11887ae..6ab840d 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -12,11 +12,7 @@ pub struct Server {
}
impl Server {
- pub fn new(addr: String) -> Result<Server, Box<dyn std::error::Error>> {
- let mut config = Config::from_env();
- config.bind_addr = addr;
- config.issuer_url = format!("http://{}", config.bind_addr);
-
+ pub fn new(config: Config) -> Result<Server, Box<dyn std::error::Error>> {
Ok(Server {
oauth_server: OAuthServer::new(&config)?,
config,
diff --git a/src/main.rs b/src/main.rs
index 6b31f92..9e5c414 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,12 +1,9 @@
use sts::http::Server;
+use sts::Config;
fn main() {
- let bind_addr: String = match std::env::var("BIND_ADDR") {
- Ok(val) => val,
- Err(_) => String::from("127.0.0.1:7878"),
- };
-
- let server = Server::new(bind_addr).expect("Failed to create server");
+ let config = Config::from_env();
+ let server = Server::new(config).expect("Failed to create server");
server.start();
}
@@ -17,7 +14,10 @@ mod tests {
#[test]
fn test_oauth_server_creation() {
- let server = sts::http::Server::new("127.0.0.1:0".to_string());
+ let mut config = sts::Config::from_env();
+ config.bind_addr = "127.0.0.1:0".to_string();
+ config.issuer_url = format!("http://{}", config.bind_addr);
+ let server = sts::http::Server::new(config);
assert!(server.is_ok());
}