Ejemplo n.º 1
0
        public virtual async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            IBucketService service = testServer.Host.Services.GetService(typeof(IBucketService)) as IBucketService;
            var            model   = new ApiBucketServerRequestModel();

            model.SetProperties(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B");
            CreateResponse <ApiBucketServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.BucketDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiBucketServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
Ejemplo n.º 2
0
 public void Init()
 {
     Access.SetTempDirectory(System.IO.Path.GetTempPath());
     _access        = new Access(TestConstants.SATELLITE_URL, TestConstants.VALID_API_KEY, TestConstants.ENCRYPTION_SECRET);
     _bucketService = new BucketService(_access);
     _objectService = new ObjectService(_access);
 }
Ejemplo n.º 3
0
 public ManageBuckets(ITomatoService tomatoService, IBucketService bucketService)
 {
     _tomatoService = tomatoService;
     _bucketService = bucketService;
     InitializeComponent();
     LoadBuckets();
 }
Ejemplo n.º 4
0
        public virtual async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            var mapper = new ApiBucketServerModelMapper();
            ApplicationDbContext         context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IBucketService               service = testServer.Host.Services.GetService(typeof(IBucketService)) as IBucketService;
            ApiBucketServerResponseModel model   = await service.Get(1);

            ApiBucketClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B");

            UpdateResponse <ApiBucketClientResponseModel> updateResponse = await client.BucketUpdateAsync(model.Id, request);

            context.Entry(context.Set <Bucket>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Bucket>().ToList()[0].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <Bucket>().ToList()[0].Name.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            updateResponse.Record.Name.Should().Be("B");
        }
Ejemplo n.º 5
0
 public DownloadObjectCommand(BucketContentViewModel senderView, IBucketService bucketService, IObjectService objectService, string bucketName)
 {
     _senderView    = senderView;
     _bucketService = bucketService;
     _objectService = objectService;
     _bucketName    = bucketName;
 }
Ejemplo n.º 6
0
 public UploadFileCommand(BucketContentViewModel senderView, IObjectService objectService, IBucketService bucketService, ILoginService loginService)
 {
     _senderView    = senderView;
     _objectService = objectService;
     _bucketService = bucketService;
     _loginService  = loginService;
 }
        public BucketServiceUnitTests()
        {
            var clientFactory = new BlipClientFactory();
            var sender        = clientFactory.BuildBlipClient("dGVzdGluZ2JvdHM6OU8zZEpWbHVaSWZNYmVnOWZaZzM=", Models.BlipProtocol.Http);

            _bucketService = new BucketService(sender);
            _logger        = Substitute.For <ILogger>();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Static Constructor to init default dependencies on application load.
 /// </summary>
 static VWO()
 {
     Validator          = new Validator();
     UserHasher         = new Murmur32BucketService();
     CampaignAllocator  = new CampaignAllocator(UserHasher);
     VariationAllocator = new VariationAllocator(UserHasher);
     SettingsProcessor  = new SettingsProcessor();
 }
Ejemplo n.º 9
0
        public BucketEntryViewModel(BucketContentViewModel bucketContentViewModel, IBucketService bucketService, IObjectService objectService)
        {
            _bucketContentViewModel = bucketContentViewModel;

            DownloadObjectCommand = new DownloadObjectCommand(bucketContentViewModel, bucketService, objectService, bucketContentViewModel.BucketName);
            DeleteObjectCommand   = new DeleteObjectCommand(bucketService, objectService);
            CancelUploadCommand   = new CancelUploadCommand(bucketService, objectService);
            CancelDownloadCommand = new CancelDownloadCommand(bucketService, objectService);
            ShowErrorCommand      = new ShowErrorCommand();
        }
            public async Task ShouldGetBucketAndWaitForAvailability(
                RequestMessage request,
                [Frozen] IBucketService service,
                [Target] DefaultRequestInvoker invoker,
                CancellationToken cancellationToken
                )
            {
                await invoker.Invoke(request, cancellationToken);

                await service.Received().GetBucketAndWaitForAvailability(Is(request.RequestDetails), Is(cancellationToken));
            }
        public BucketContentViewModel(IObjectService objectService, IBucketService bucketService, ILoginService loginService)
        {
            Entries = new ObservableCollection <BucketEntryViewModel>();

            _objectService = objectService;
            _bucketService = bucketService;
            _loginService  = loginService;

            GoBackCommand     = new GoBackCommand();
            UploadFileCommand = new UploadFileCommand(this, _objectService, _bucketService, _loginService);
        }
Ejemplo n.º 12
0
 public AbstractBucketController(
     ApiSettings settings,
     ILogger <AbstractBucketController> logger,
     ITransactionCoordinator transactionCoordinator,
     IBucketService bucketService,
     IApiBucketModelMapper bucketModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.BucketService     = bucketService;
     this.BucketModelMapper = bucketModelMapper;
 }
Ejemplo n.º 13
0
        public BucketListViewModel(IBucketService bucketService)
        {
            _bucketService = bucketService;

            LogoutCommand       = new LogoutCommand(Factory.LoginService);
            CreateBucketCommand = new CreateBucketCommand();
            DeleteBucketCommand = new DeleteBucketCommand(_bucketService);

            Buckets = new ObservableCollection <NET.Sample.Shared.ViewModels.BucketInfoViewModel>();

            LoadBuckets();
        }
Ejemplo n.º 14
0
 public AppData(ISecureStorage secureStorage, IUserData userData, IUserCardsService userCardsService, IRatesService ratesService, IBucketService bucketService, IUserAssetsService userAssetsService, IRatesData ratesData, ICardData cardData, IBucketData bucketData)
 {
     this.secureStorage     = secureStorage;
     this.userData          = userData;
     this.userCardsService  = userCardsService;
     this.ratesService      = ratesService;
     this.bucketService     = bucketService;
     this.userAssetsService = userAssetsService;
     this.ratesData         = ratesData;
     this.cardData          = cardData;
     this.bucketData        = bucketData;
 }
Ejemplo n.º 15
0
        // ReSharper disable once UnusedMember.Global
        // This constructor is needed by the BackendLoader.
        public Tardigrade(string url, Dictionary <string, string> options)
        {
            InitStorjLibrary();

            var auth_method = options[TARDIGRADE_AUTH_METHOD];

            if (auth_method == "Access grant")
            {
                //Create an access from the access grant
                var shared_access = options[TARDIGRADE_SHARED_ACCESS];
                _access = new Access(shared_access, new Config()
                {
                    UserAgent = TARDIGRADE_PARTNER_ID
                });
            }
            else
            {
                //Create an access for a satellite, API key and encryption passphrase
                _satellite = options[TARDIGRADE_SATELLITE];

                if (options.ContainsKey(TARDIGRADE_API_KEY))
                {
                    _api_key = options[TARDIGRADE_API_KEY];
                }
                if (options.ContainsKey(TARDIGRADE_SECRET))
                {
                    _secret = options[TARDIGRADE_SECRET];
                }

                _access = new Access(_satellite, _api_key, _secret, new Config()
                {
                    UserAgent = TARDIGRADE_PARTNER_ID
                });
            }

            _bucketService = new BucketService(_access);
            _objectService = new ObjectService(_access);

            //If no bucket was provided use the default "duplicati"-bucket
            if (options.ContainsKey(TARDIGRADE_BUCKET))
            {
                _bucket = options[TARDIGRADE_BUCKET];
            }
            else
            {
                _bucket = "duplicati";
            }

            if (options.ContainsKey(TARDIGRADE_FOLDER))
            {
                _folder = options[TARDIGRADE_FOLDER];
            }
        }
Ejemplo n.º 16
0
 public BucketController(
     ApiSettings settings,
     ILogger <BucketController> logger,
     ITransactionCoordinator transactionCoordinator,
     IBucketService bucketService,
     IApiBucketServerModelMapper bucketModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.BucketService     = bucketService;
     this.BucketModelMapper = bucketModelMapper;
     this.BulkInsertLimit   = 250;
     this.MaxLimit          = 1000;
     this.DefaultLimit      = 250;
 }
            public async Task ShouldUpdateBucketResetAfter(
                RequestMessage request,
                [Frozen] Bucket bucket,
                [Frozen] HttpResponseMessage responseMessage,
                [Frozen, Substitute] IBucketService bucketService,
                [Frozen, Substitute] HttpMessageInvoker client,
                [Frozen, Substitute] IUrlBuilder urlBuilder,
                [Target] DefaultRequestInvoker invoker,
                CancellationToken cancellationToken
                )
            {
                await invoker.Invoke(request, cancellationToken);

                bucketService.Received().UpdateBucketResetAfter(Is(bucket), Is(responseMessage));
            }
Ejemplo n.º 18
0
 public void Dispose()
 {
     if (_objectService != null)
     {
         _objectService = null;
     }
     if (_bucketService != null)
     {
         _bucketService = null;
     }
     if (_access != null)
     {
         _access.Dispose();
         _access = null;
     }
 }
Ejemplo n.º 19
0
        // ReSharper disable once UnusedMember.Global
        // This constructor is needed by the BackendLoader.
        public Tardigrade(string url, Dictionary <string, string> options)
        {
            var auth_method = options[TARDIGRADE_AUTH_METHOD];

            Access.SetTempDirectory(System.IO.Path.GetTempPath());

            if (auth_method == "Access grant")
            {
                //Create an access from the access grant
                var shared_access = options[TARDIGRADE_SHARED_ACCESS];
                _access = new Access(shared_access);
            }
            else
            {
                //Create an access for a satellite, API key and encryption passphrase
                _satellite = options[TARDIGRADE_SATELLITE];

                if (options.ContainsKey(TARDIGRADE_API_KEY))
                {
                    _api_key = options[TARDIGRADE_API_KEY];
                }
                if (options.ContainsKey(TARDIGRADE_SECRET))
                {
                    _secret = options[TARDIGRADE_SECRET];
                }

                _access = new Access(_satellite, _api_key, _secret);
            }

            _bucketService = new BucketService(_access);
            _objectService = new ObjectService(_access);

            //If no bucket was provided use the default "duplicati"-bucket
            if (options.ContainsKey(TARDIGRADE_BUCKET))
            {
                _bucket = options[TARDIGRADE_BUCKET];
            }
            else
            {
                _bucket = "duplicati";
            }

            if (options.ContainsKey(TARDIGRADE_FOLDER))
            {
                _folder = options[TARDIGRADE_FOLDER];
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRequestInvoker" /> class.
 /// </summary>
 /// <param name="client">Client used to send/recieve http messages.</param>
 /// <param name="urlBuilder">Builder used to build URLs from requests.</param>
 /// <param name="relay">Service used to relay messages back and forth between SQS.</param>
 /// <param name="bucketService">Service used to manage buckets.</param>
 /// <param name="bucketRepository">Repository to manage buckets.</param>
 /// <param name="reporter">Service used to report metrics.</param>
 /// <param name="logger">Logger used to log info to some destination(s).</param>
 public DefaultRequestInvoker(
     HttpMessageInvoker client,
     IUrlBuilder urlBuilder,
     IRequestMessageRelay relay,
     IBucketService bucketService,
     IBucketRepository bucketRepository,
     IMetricReporter reporter,
     ILogger <DefaultRequestInvoker> logger
     )
 {
     this.client           = client;
     this.urlBuilder       = urlBuilder;
     this.relay            = relay;
     this.bucketService    = bucketService;
     this.bucketRepository = bucketRepository;
     this.reporter         = reporter;
     this.logger           = logger;
 }
Ejemplo n.º 21
0
        public BucketsViewModel(
            IBucketService bucketSvc,
            LogViewModel logVm,
            AddTab addTab)
        {
            _bucketSvc = bucketSvc ?? throw new ArgumentNullException(nameof(bucketSvc));
            _logVm     = logVm ?? throw new ArgumentNullException(nameof(logVm));

            _tabs = new ObservableCollection <IBucketTab>();

            _tabs.Add(logVm);
            _tabs.Add(addTab);
            SelectedTab = _tabs.First();

            CloseTabCommand = new CommandHandler <IBucketTab>(CloseTab);
            AddTabCommand   = new CommandHandler(AddTab);

            LoadBuckets();
        }
Ejemplo n.º 22
0
 /*------------------------ METHODS REGION ------------------------*/
 public BucketController(IBucketService bucketService)
 {
     _bucketService = bucketService;
 }
Ejemplo n.º 23
0
 public DeleteObjectCommand(IBucketService bucketService, IObjectService objectService)
 {
     _bucketService = bucketService;
     _objectService = objectService;
 }
Ejemplo n.º 24
0
 internal VariationAllocator(IBucketService userHasher = null)
 {
     this._userHasher = userHasher;
 }
Ejemplo n.º 25
0
 public Form1(ITomatoService tomatoService, IBucketService bucketService)
 {
     _tomatoService = tomatoService;
     _bucketService = bucketService;
     Setup();
 }
Ejemplo n.º 26
0
 public SaveBucketCommand(IBucketService bucketService)
 {
     _bucketService = bucketService;
 }
Ejemplo n.º 27
0
 public DeleteBucketCommand(IBucketService bucketService)
 {
     _bucketService = bucketService;
 }
Ejemplo n.º 28
0
 internal CampaignAllocator(IBucketService userHasher)
 {
     this._userHasher = userHasher;
 }
Ejemplo n.º 29
0
 public BucketsController(IBucketService service)
 {
     _service = service;
 }
Ejemplo n.º 30
0
 public CancelUploadCommand(IBucketService bucketService, IObjectService objectService)
 {
     _bucketService = bucketService;
     _objectService = objectService;
 }
 public DocumentProcessor()
 {
     this.bucketService = new BucketService();
     this.repository    = new DocumentRepository();
 }
Ejemplo n.º 32
0
 public BucketsController(IUserService userService, IBucketService bucketService)
 {
     _bucketService = bucketService;
     _userService   = userService;
 }