Exemple #1
0
        public async Task GivenInvalidAuthorization_WhenHandlingRequest_ThenThrowUnauthorizedDicomActionException()
        {
            using var source = new CancellationTokenSource();
            IAuthorizationService <DataActions> auth = Substitute.For <IAuthorizationService <DataActions> >();
            IDicomOperationsClient client            = Substitute.For <IDicomOperationsClient>();
            var handler = new OperationStatusHandler(auth, client);

            auth.CheckAccess(DataActions.Read, source.Token).Returns(DataActions.None);

            await Assert.ThrowsAsync <UnauthorizedDicomActionException>(() => handler.Handle(new OperationStatusRequest(Guid.NewGuid()), source.Token));

            await auth.Received(1).CheckAccess(DataActions.Read, source.Token);

            await client.DidNotReceiveWithAnyArgs().GetStatusAsync(default, default);
Exemple #2
0
        public AddExtendedQueryTagServiceTests()
        {
            _extendedQueryTagStore = Substitute.For <IExtendedQueryTagStore>();
            _client = Substitute.For <IDicomOperationsClient>();
            _extendedQueryTagEntryValidator = Substitute.For <IExtendedQueryTagEntryValidator>();
            _urlResolver             = Substitute.For <IUrlResolver>();
            _extendedQueryTagService = new AddExtendedQueryTagService(
                _extendedQueryTagStore,
                _client,
                _extendedQueryTagEntryValidator,
                _urlResolver,
                Options.Create(new ExtendedQueryTagConfiguration {
                MaxAllowedCount = 128
            }));

            _tokenSource = new CancellationTokenSource();
        }
        public AddExtendedQueryTagService(
            IExtendedQueryTagStore extendedQueryTagStore,
            IDicomOperationsClient client,
            IExtendedQueryTagEntryValidator extendedQueryTagEntryValidator,
            IUrlResolver uriResolver,
            IOptions <ExtendedQueryTagConfiguration> extendedQueryTagConfiguration)
        {
            EnsureArg.IsNotNull(extendedQueryTagStore, nameof(extendedQueryTagStore));
            EnsureArg.IsNotNull(client, nameof(client));
            EnsureArg.IsNotNull(extendedQueryTagEntryValidator, nameof(extendedQueryTagEntryValidator));
            EnsureArg.IsNotNull(uriResolver, nameof(uriResolver));
            EnsureArg.IsNotNull(extendedQueryTagConfiguration?.Value, nameof(extendedQueryTagConfiguration));

            _extendedQueryTagStore = extendedQueryTagStore;
            _client = client;
            _extendedQueryTagEntryValidator = extendedQueryTagEntryValidator;
            _uriResolver     = uriResolver;
            _maxAllowedCount = extendedQueryTagConfiguration.Value.MaxAllowedCount;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="OperationStatusHandler"/> class.
 /// </summary>
 /// <param name="authorizationService">A service for determining if a user is authorized.</param>
 /// <param name="client">A client for interacting with DICOM operations.</param>
 /// <exception cref="ArgumentNullException"><paramref name="client"/> is <see langword="null"/>.</exception>
 public OperationStatusHandler(IAuthorizationService <DataActions> authorizationService, IDicomOperationsClient client)
     : base(authorizationService)
     => _client = EnsureArg.IsNotNull(client, nameof(client));