Skip to content

Commit

Permalink
Moved DatasetFactory & OdfServerAccessTokenResolver to odf-dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
zaychenko-sergei committed Dec 26, 2024
1 parent 8291fe2 commit ab54f82
Show file tree
Hide file tree
Showing 74 changed files with 194 additions and 99 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,5 @@ ignore = [
"RUSTSEC-2024-0370",
# Unmaintained (instant)
# https://rustsec.org/advisories/RUSTSEC-2024-0384.html
"RUSTSEC-2024-0384",
# Security: requires update in hickory-resolver, which is not available yet
# https://github.com/rust-lang/crates.io-index
"RUSTSEC-2024-0421"
"RUSTSEC-2024-0384"
]
3 changes: 2 additions & 1 deletion src/adapter/http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ kamu-datasets-services = { workspace = true }
kamu-datasets-inmem = { workspace = true }
kamu-ingest-datafusion = { workspace = true }
messaging-outbox = { workspace = true }
odf-storage-impl = { workspace = true, features = ["testing"]}
odf-dataset-impl = { workspace = true, features = ["testing"] }
odf-storage-impl = { workspace = true, features = ["testing"] }
test-utils = { workspace = true }

fs_extra = "1.3" # Recursive folder copy
Expand Down
13 changes: 10 additions & 3 deletions src/adapter/http/src/smart_protocol/ws_tungstenite_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ use internal_error::{ErrorIntoInternal, InternalError, ResultIntoInternal};
use kamu::utils::smart_transfer_protocol::{SmartTransferProtocolClient, TransferOptions};
use kamu_core::*;
use odf::AsTypedBlock;
use odf_dataset::{BlockRef, Dataset, DatasetVisibility, InvalidIntervalError, RefCASError};
use odf_dataset::{
BlockRef,
Dataset,
DatasetVisibility,
InvalidIntervalError,
OdfServerAccessTokenResolver,
RefCASError,
};
use odf_storage::GetRefError;
use opendatafabric as odf;
use serde::de::DeserializeOwned;
Expand All @@ -39,7 +46,7 @@ use crate::OdfSmtpVersion;

pub struct WsSmartTransferProtocolClient {
catalog: Catalog,
dataset_credential_resolver: Arc<dyn auth::OdfServerAccessTokenResolver>,
dataset_credential_resolver: Arc<dyn OdfServerAccessTokenResolver>,
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -49,7 +56,7 @@ pub struct WsSmartTransferProtocolClient {
impl WsSmartTransferProtocolClient {
pub fn new(
catalog: Catalog,
dataset_credential_resolver: Arc<dyn auth::OdfServerAccessTokenResolver>,
dataset_credential_resolver: Arc<dyn OdfServerAccessTokenResolver>,
) -> Self {
Self {
catalog,
Expand Down
10 changes: 5 additions & 5 deletions src/adapter/http/tests/harness/client_side_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;

use auth::OdfServerAccessTokenResolver;
use container_runtime::ContainerRuntime;
use database_common::NoOpDatabasePlugin;
use dill::Component;
Expand All @@ -25,7 +24,8 @@ use kamu_adapter_http::{OdfSmtpVersion, SmartTransferProtocolClientWs};
use kamu_datasets_inmem::InMemoryDatasetDependencyRepository;
use kamu_datasets_services::{DatasetKeyValueServiceSysEnv, DependencyGraphServiceImpl};
use messaging_outbox::DummyOutboxImpl;
use odf_dataset::DatasetVisibility;
use odf_dataset::{DatasetVisibility, OdfServerAccessTokenResolver};
use odf_dataset_impl::{DatasetFactoryImpl, DatasetLayout, IpfsGateway};
use opendatafabric::{
AccountID,
AccountName,
Expand Down Expand Up @@ -94,10 +94,10 @@ impl ClientSideHarness {
b.add::<auth::AlwaysHappyDatasetActionAuthorizer>();

if options.authenticated_remotely {
b.add::<auth::DummyOdfServerAccessTokenResolver>();
b.add::<odf_dataset::DummyOdfServerAccessTokenResolver>();
} else {
b.add_value(kamu::testing::MockOdfServerAccessTokenResolver::empty());
b.bind::<dyn auth::OdfServerAccessTokenResolver, kamu::testing::MockOdfServerAccessTokenResolver>();
b.add_value(odf_dataset_impl::testing::MockOdfServerAccessTokenResolver::empty());
b.bind::<dyn odf_dataset::OdfServerAccessTokenResolver, odf_dataset_impl::testing::MockOdfServerAccessTokenResolver>();
}

b.add::<SystemTimeSourceDefault>();
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/http/tests/harness/common_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use datafusion::arrow::array::{Array, RecordBatch, UInt64Array};
use datafusion::arrow::datatypes::{DataType, Field, Schema};
use kamu::domain::*;
use kamu::testing::ParquetWriterHelper;
use kamu::DatasetLayout;
use odf_dataset::{CommitOpts, CommitResult};
use odf_dataset_impl::DatasetLayout;
use odf_storage::{InsertOpts, ObjectRepository};
use odf_storage_impl::testing::{AddDataBuilder, MetadataFactory};
use odf_storage_impl::ObjectRepositoryLocalFSSha3;
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/http/tests/harness/server_side_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use kamu::domain::{
CreateDatasetUseCase,
};
use kamu::testing::MockDatasetActionAuthorizer;
use kamu::DatasetLayout;
use kamu_accounts::testing::MockAuthenticationService;
use kamu_accounts::{Account, AccountType, CurrentAccountSubject, PROVIDER_PASSWORD};
use kamu_core::{CompactionExecutor, CompactionPlanner, DatasetRegistry, TenancyConfig};
use odf_dataset_impl::DatasetLayout;
use opendatafabric::{AccountID, AccountName, DatasetAlias, DatasetHandle};
use reqwest::Url;
use time_source::SystemTimeSourceStub;
Expand Down Expand Up @@ -84,7 +84,7 @@ pub(crate) struct ServerSideHarnessOptions {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

pub(crate) fn server_authentication_mock(account: &Account) -> MockAuthenticationService {
MockAuthenticationService::resolving_token(kamu_accounts::DUMMY_ACCESS_TOKEN, account.clone())
MockAuthenticationService::resolving_token(odf_dataset::DUMMY_ODF_ACCESS_TOKEN, account.clone())
}

pub(crate) fn make_server_account() -> Account {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use kamu::{
CompactionPlannerImpl,
CreateDatasetFromSnapshotUseCaseImpl,
CreateDatasetUseCaseImpl,
DatasetLayout,
DatasetRegistryRepoBridge,
DatasetRepositoryLocalFs,
DatasetRepositoryWriter,
Expand All @@ -44,6 +43,7 @@ use kamu_core::{CompactionExecutor, CompactionPlanner, DatasetRegistry, TenancyC
use kamu_datasets_inmem::InMemoryDatasetDependencyRepository;
use kamu_datasets_services::DependencyGraphServiceImpl;
use messaging_outbox::DummyOutboxImpl;
use odf_dataset_impl::DatasetLayout;
use opendatafabric::{AccountName, DatasetAlias, DatasetHandle};
use tempfile::TempDir;
use time_source::{SystemTimeSource, SystemTimeSourceStub};
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/http/tests/harness/server_side_s3_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use kamu::{
CompactionPlannerImpl,
CreateDatasetFromSnapshotUseCaseImpl,
CreateDatasetUseCaseImpl,
DatasetLayout,
DatasetRegistryRepoBridge,
DatasetRepositoryS3,
DatasetRepositoryWriter,
Expand All @@ -46,6 +45,7 @@ use kamu_core::{DatasetRegistry, TenancyConfig};
use kamu_datasets_inmem::InMemoryDatasetDependencyRepository;
use kamu_datasets_services::DependencyGraphServiceImpl;
use messaging_outbox::DummyOutboxImpl;
use odf_dataset_impl::DatasetLayout;
use opendatafabric::{AccountName, DatasetAlias, DatasetHandle};
use s3_utils::S3Context;
use test_utils::LocalS3Server;
Expand Down
6 changes: 4 additions & 2 deletions src/adapter/http/tests/tests/test_account_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use kamu_accounts::DUMMY_ACCESS_TOKEN;
use kamu_core::{RunInfoDir, TenancyConfig};
use serde_json::json;

Expand Down Expand Up @@ -50,7 +49,10 @@ async fn test_get_account_info() {

let res = cl
.get(&format!("{}accounts/me", harness.root_url))
.header("Authorization", format!("Bearer {DUMMY_ACCESS_TOKEN}"))
.header(
"Authorization",
format!("Bearer {}", odf_dataset::DUMMY_ODF_ACCESS_TOKEN),
)
.send()
.await
.unwrap();
Expand Down
9 changes: 4 additions & 5 deletions src/adapter/http/tests/tests/test_data_ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use indoc::indoc;
use kamu::domain::*;
use kamu::testing::DatasetDataHelper;
use kamu::*;
use kamu_accounts::DUMMY_ACCESS_TOKEN;
use kamu_adapter_http::{
FileUploadLimitConfig,
UploadServiceLocal,
Expand Down Expand Up @@ -318,7 +317,7 @@ async fn test_data_push_ingest_upload_token_no_initial_source() {
let res = cl
.execute(
cl.post(&ingest_url)
.bearer_auth(DUMMY_ACCESS_TOKEN)
.bearer_auth(odf_dataset::DUMMY_ODF_ACCESS_TOKEN)
.build()
.unwrap(),
)
Expand Down Expand Up @@ -406,7 +405,7 @@ async fn test_data_push_ingest_upload_token_with_initial_source() {
let res = cl
.execute(
cl.post(&ingest_url)
.bearer_auth(DUMMY_ACCESS_TOKEN)
.bearer_auth(odf_dataset::DUMMY_ODF_ACCESS_TOKEN)
.build()
.unwrap(),
)
Expand Down Expand Up @@ -485,7 +484,7 @@ async fn test_data_push_ingest_upload_content_type_not_specified() {

cl.execute(
cl.post(&ingest_url)
.bearer_auth(DUMMY_ACCESS_TOKEN)
.bearer_auth(odf_dataset::DUMMY_ODF_ACCESS_TOKEN)
.build()
.unwrap(),
)
Expand Down Expand Up @@ -573,7 +572,7 @@ async fn test_data_push_ingest_upload_token_actual_file_different_size() {
let res = cl
.execute(
cl.post(&ingest_url)
.bearer_auth(DUMMY_ACCESS_TOKEN)
.bearer_auth(odf_dataset::DUMMY_ODF_ACCESS_TOKEN)
.build()
.unwrap(),
)
Expand Down
11 changes: 8 additions & 3 deletions src/adapter/http/tests/tests/test_dataset_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// by the Apache License, Version 2.0.

use chrono::Utc;
use kamu_accounts::DUMMY_ACCESS_TOKEN;
use kamu_core::TenancyConfig;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::{DatasetAlias, DatasetID, DatasetKind, DatasetName};
Expand Down Expand Up @@ -44,7 +43,10 @@ async fn test_get_dataset_info_by_id() {
"{}datasets/{}",
harness.root_url, create_result.dataset_handle.id
))
.header("Authorization", format!("Bearer {DUMMY_ACCESS_TOKEN}"))
.header(
"Authorization",
format!("Bearer {}", odf_dataset::DUMMY_ODF_ACCESS_TOKEN),
)
.send()
.await
.unwrap()
Expand Down Expand Up @@ -75,7 +77,10 @@ async fn test_get_dataset_info_by_id_not_found_err() {

let res = cl
.get(&format!("{}datasets/{dataset_id}", harness.root_url))
.header("Authorization", format!("Bearer {DUMMY_ACCESS_TOKEN}"))
.header(
"Authorization",
format!("Bearer {}", odf_dataset::DUMMY_ODF_ACCESS_TOKEN),
)
.send()
.await
.unwrap();
Expand Down
5 changes: 3 additions & 2 deletions src/adapter/http/tests/tests/test_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use kamu_accounts::CurrentAccountSubject;
use kamu_datasets_inmem::InMemoryDatasetDependencyRepository;
use kamu_datasets_services::DependencyGraphServiceImpl;
use messaging_outbox::DummyOutboxImpl;
use odf_dataset::BlockRef;
use odf_dataset::{BlockRef, DatasetFactory, DummyOdfServerAccessTokenResolver};
use odf_dataset_impl::{DatasetFactoryImpl, IpfsGateway};
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;
use time_source::SystemTimeSourceDefault;
Expand Down Expand Up @@ -131,7 +132,7 @@ where

async fn setup_client(dataset_url: url::Url, head_expected: Multihash) {
let catalog = dill::CatalogBuilder::new()
.add::<auth::DummyOdfServerAccessTokenResolver>()
.add::<DummyOdfServerAccessTokenResolver>()
.build();

let dataset = DatasetFactoryImpl::new(IpfsGateway::default(), catalog.get_one().unwrap())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// by the Apache License, Version 2.0.

use kamu::domain::*;
use kamu::DatasetLayout;
use odf_dataset::{CommitOpts, CommitResult};
use odf_dataset_impl::DatasetLayout;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use kamu::DatasetLayout;
use odf_dataset::CommitResult;
use odf_dataset_impl::DatasetLayout;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// by the Apache License, Version 2.0.

use kamu::domain::*;
use kamu::DatasetLayout;
use odf_dataset::CommitResult;
use odf_dataset_impl::DatasetLayout;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// by the Apache License, Version 2.0.

use kamu::domain::*;
use kamu::DatasetLayout;
use odf_dataset::{CommitOpts, CommitResult};
use odf_dataset_impl::DatasetLayout;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use kamu::DatasetLayout;
use odf_dataset_impl::DatasetLayout;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use kamu::DatasetLayout;
use odf_dataset::CommitResult;
use odf_dataset_impl::DatasetLayout;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// by the Apache License, Version 2.0.

use kamu::domain::*;
use kamu::DatasetLayout;
use odf_dataset_impl::DatasetLayout;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use kamu::DatasetLayout;
use odf_dataset::CommitResult;
use odf_dataset_impl::DatasetLayout;
use odf_storage_impl::testing::MetadataFactory;
use opendatafabric::*;

Expand Down
Loading

0 comments on commit ab54f82

Please sign in to comment.