Skip to content

Commit 0e69f4a

Browse files
Run full test suite and fix any failures\n\nTask ID: task-5.1-final-validation
1 parent 4412dba commit 0e69f4a

File tree

4 files changed

+31
-26
lines changed

4 files changed

+31
-26
lines changed

rust/src/auth/oauth/callback.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,10 @@ impl CallbackServer {
212212
/// Returns the redirect URI for this callback server.
213213
///
214214
/// This URI should be used when constructing the OAuth authorization URL.
215-
/// The format is `http://localhost:{port}/callback`.
215+
/// The format is `http://localhost:{port}` (matching the redirect URI
216+
/// registered for the `databricks-cli` OAuth application).
216217
pub fn redirect_uri(&self) -> String {
217-
format!("http://localhost:{}/callback", self.port)
218+
format!("http://localhost:{}", self.port)
218219
}
219220

220221
/// Waits for the OAuth callback with the authorization code.
@@ -336,7 +337,7 @@ impl CallbackServer {
336337

337338
let request = String::from_utf8_lossy(&buffer[..n]);
338339

339-
// Parse the request line (e.g., "GET /callback?code=...&state=... HTTP/1.1")
340+
// Parse the request line (e.g., "GET /?code=...&state=... HTTP/1.1")
340341
let first_line = request.lines().next().unwrap_or("");
341342
let parts: Vec<&str> = first_line.split_whitespace().collect();
342343

@@ -484,7 +485,7 @@ mod tests {
484485
.expect("Failed to connect to callback server");
485486

486487
let request = format!(
487-
"GET /callback?code=test-auth-code-123&state={} HTTP/1.1\r\nHost: localhost:{}\r\n\r\n",
488+
"GET /?code=test-auth-code-123&state={} HTTP/1.1\r\nHost: localhost:{}\r\n\r\n",
488489
expected_state, port
489490
);
490491

@@ -525,7 +526,7 @@ mod tests {
525526
.expect("Failed to connect");
526527

527528
let request = format!(
528-
"GET /callback?code=auth-code&state={} HTTP/1.1\r\nHost: localhost:{}\r\n\r\n",
529+
"GET /?code=auth-code&state={} HTTP/1.1\r\nHost: localhost:{}\r\n\r\n",
529530
wrong_state, port
530531
);
531532

@@ -589,7 +590,7 @@ mod tests {
589590

590591
// Send callback without 'code' parameter
591592
let request = format!(
592-
"GET /callback?state=test-state HTTP/1.1\r\nHost: localhost:{}\r\n\r\n",
593+
"GET /?state=test-state HTTP/1.1\r\nHost: localhost:{}\r\n\r\n",
593594
port
594595
);
595596

@@ -620,7 +621,7 @@ mod tests {
620621

621622
// Simulate authorization server error response
622623
let request = format!(
623-
"GET /callback?error=access_denied&error_description=User%20denied%20consent HTTP/1.1\r\nHost: localhost:{}\r\n\r\n",
624+
"GET /?error=access_denied&error_description=User%20denied%20consent HTTP/1.1\r\nHost: localhost:{}\r\n\r\n",
624625
port
625626
);
626627

@@ -671,6 +672,6 @@ mod tests {
671672
let server = CallbackServer::new(8020)
672673
.await
673674
.expect("Failed to create server");
674-
assert_eq!(server.redirect_uri(), "http://localhost:8020/callback");
675+
assert_eq!(server.redirect_uri(), "http://localhost:8020");
675676
}
676677
}

rust/src/auth/oauth/m2m.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ impl ClientCredentialsProvider {
188188
token_endpoint_override: Option<String>,
189189
) -> Result<Self> {
190190
// Discover OIDC endpoints or use override
191-
let (token_endpoint, auth_endpoint) = if let Some(token_endpoint) = token_endpoint_override {
191+
let (token_endpoint, auth_endpoint) = if let Some(token_endpoint) = token_endpoint_override
192+
{
192193
// Use override for token endpoint, still discover auth endpoint
193194
// (auth endpoint is not typically overridden for M2M since it's not used)
194195
let endpoints = OidcEndpoints::discover(host, &http_client).await?;

rust/src/database.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -662,25 +662,32 @@ impl adbc_core::Database for Database {
662662
}
663663
AuthFlow::ClientCredentials => {
664664
// Client credentials flow (M2M) - create ClientCredentialsProvider
665-
let client_id = self.auth_client_id.as_ref()
665+
let client_id = self
666+
.auth_client_id
667+
.as_ref()
666668
.expect("client_id should be validated above");
667-
let client_secret = self.auth_client_secret.as_ref()
669+
let client_secret = self
670+
.auth_client_secret
671+
.as_ref()
668672
.expect("client_secret should be validated above");
669673

670674
// Default scope for M2M is "all-apis" (no offline_access since M2M has no refresh token)
671675
let scopes_str = self.auth_scopes.as_deref().unwrap_or("all-apis");
672-
let scopes: Vec<String> = scopes_str.split_whitespace().map(String::from).collect();
676+
let scopes: Vec<String> =
677+
scopes_str.split_whitespace().map(String::from).collect();
673678

674679
// Create the provider (async operation - needs runtime)
675680
let provider = runtime
676-
.block_on(crate::auth::ClientCredentialsProvider::new_with_full_config(
677-
host,
678-
client_id,
679-
client_secret,
680-
http_client.clone(),
681-
scopes,
682-
self.auth_token_endpoint.clone(),
683-
))
681+
.block_on(
682+
crate::auth::ClientCredentialsProvider::new_with_full_config(
683+
host,
684+
client_id,
685+
client_secret,
686+
http_client.clone(),
687+
scopes,
688+
self.auth_token_endpoint.clone(),
689+
),
690+
)
684691
.map_err(|e| e.to_adbc())?;
685692

686693
Arc::new(provider)

rust/tests/oauth_e2e.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ fn test_m2m_end_to_end() {
129129

130130
// Create driver and database
131131
let mut driver = Driver::new();
132-
let mut database = driver
133-
.new_database()
134-
.expect("Failed to create database");
132+
let mut database = driver.new_database().expect("Failed to create database");
135133

136134
// Configure database with M2M OAuth
137135
database
@@ -286,9 +284,7 @@ fn test_u2m_end_to_end() {
286284

287285
// Create driver and database
288286
let mut driver = Driver::new();
289-
let mut database = driver
290-
.new_database()
291-
.expect("Failed to create database");
287+
let mut database = driver.new_database().expect("Failed to create database");
292288

293289
// Configure database with U2M OAuth
294290
database

0 commit comments

Comments
 (0)