public FileSystemNonceStoreTests() { FakeFactory.Create(out _systemClock); _now = new DateTimeOffset( DateTimeOffset.UtcNow.Year, DateTimeOffset.UtcNow.Month, DateTimeOffset.UtcNow.Day, DateTimeOffset.UtcNow.Hour, DateTimeOffset.UtcNow.Minute, DateTimeOffset.UtcNow.Second, DateTimeOffset.UtcNow.Millisecond, TimeSpan.Zero); A.CallTo(() => _systemClock.UtcNow) .Returns(_now); var tempFilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".xml"); _fileManager = new NoncesFileManager( new FileReader(), new FileWriter(), tempFilePath, new NonceDataRecordSerializer()); _sut = new FileSystemNonceStore(_fileManager, _systemClock); }
public Compose() { var timeOfComposing = new DateTimeOffset(2020, 2, 24, 11, 20, 14, TimeSpan.FromHours(1)); var expires = TimeSpan.FromMinutes(5); var httpRequest = new HttpRequestForSignatureString { Method = HttpMethod.Post, RequestUri = "http://dalion.eu/api/resource/id1".ToUri() }; var headerNames = new[] { HeaderName.PredefinedHeaderNames.RequestTarget, HeaderName.PredefinedHeaderNames.Date, new HeaderName("dalion_app_id") }; var requestTargetEscaping = RequestTargetEscaping.Unescaped; var nonce = "abc123"; _compositionRequest = new SigningStringCompositionRequest { Request = httpRequest, Expires = expires, Nonce = nonce, HeadersToInclude = headerNames, RequestTargetEscaping = requestTargetEscaping, TimeOfComposing = timeOfComposing }; FakeFactory.Create(out _headerAppender); A.CallTo(() => _headerAppenderFactory.Create( _compositionRequest.Request, _compositionRequest.RequestTargetEscaping, _compositionRequest.TimeOfComposing, _compositionRequest.Expires)) .Returns(_headerAppender); }
public RequestSignerTests() { FakeFactory.Create( out _signatureCreator, out _authorizationHeaderParamCreator, out _dateHeaderEnsurer, out _digestHeaderEnsurer, out _systemClock, out _logger); _signingSettings = new SigningSettings { Expires = TimeSpan.FromMinutes(5), KeyId = new KeyId("client1"), SignatureAlgorithm = new HMACSignatureAlgorithm("s3cr3t", HashAlgorithmName.SHA512), Headers = new[] { HeaderName.PredefinedHeaderNames.RequestTarget, HeaderName.PredefinedHeaderNames.Date, new HeaderName("dalion_app_id") } }; _sut = new RequestSigner( _signatureCreator, _authorizationHeaderParamCreator, _signingSettings, _dateHeaderEnsurer, _digestHeaderEnsurer, _systemClock, _logger); }
public CachingClientStoreTests() { FakeFactory.Create(out _decorated, out _backgroundTaskStarter); _cache = new FakeMemoryCache(); _expiration = TimeSpan.FromSeconds(30); _sut = new CachingClientStore(_decorated, _cache, _expiration, _backgroundTaskStarter); }
public SignatureVerifierTests() { FakeFactory.Create( out _signatureSanitizer, out _knownAlgorithmVerificationTask, out _matchingAlgorithmVerificationTask, out _creationTimeVerificationTask, out _createdHeaderGuardVerificationTask, out _expiresHeaderGuardVerificationTask, out _allHeadersPresentVerificationTask, out _expirationTimeVerificationTask, out _nonceVerificationTask, out _digestVerificationTask, out _matchingSignatureStringVerificationTask); _sut = new SignatureVerifier( _signatureSanitizer, _knownAlgorithmVerificationTask, _matchingAlgorithmVerificationTask, _createdHeaderGuardVerificationTask, _expiresHeaderGuardVerificationTask, _allHeadersPresentVerificationTask, _creationTimeVerificationTask, _expirationTimeVerificationTask, _nonceVerificationTask, _digestVerificationTask, _matchingSignatureStringVerificationTask); }
public LockingNonceStoreTests() { FakeFactory.Create(out _decorated, out _lockFactory); _lock = new AsyncReaderWriterLock(); A.CallTo(() => _lockFactory.CreateLock()) .Returns(_lock); _sut = new LockingNonceStore(_decorated, _lockFactory); }
public OnlyOnceClientStoreMigratorTests() { FakeFactory.Create(out _decorated, out _baseliner, out _semaphoreFactory); _semaphore = new SemaphoreSlim(1, 1); A.CallTo(() => _semaphoreFactory.CreateLock()) .Returns(_semaphore); _sut = new OnlyOnceClientStoreMigrator(_decorated, _baseliner, _semaphoreFactory); }
public InternalServerError() { var factory = new CustomWebApplicationFactory(); _client = factory.CreateClient(); FakeFactory.Create(out _feature); _sut.HttpContext.Features.Set(_feature); }
public VerificationResultCreatorTests() { FakeFactory.Create(out _claimsPrincipalFactory); _signature = new Signature { KeyId = "client1" }; _client = new Client("client1", "Unit test app", new HMACSignatureAlgorithm("s3cr3t", HashAlgorithmName.SHA256), TimeSpan.FromMinutes(1)); _sut = new VerificationResultCreator(_client, _signature, _claimsPrincipalFactory); }
public SignatureAlgorithmDataRecordConverterTests() { FakeFactory.Create(out _stringProtectorFactory); _sut = new SignatureAlgorithmDataRecordConverter(_stringProtectorFactory); _stringProtector = new FakeStringProtector(); A.CallTo(() => _stringProtectorFactory.CreateSymmetric(A <string> ._)) .Returns(_stringProtector); }
public CompositeRequestTargetEscaperTests() { FakeFactory.Create(out _rfc2396Escaper, out _rfc3986Escaper, out _originalStringEscaper, out _unescapedEscaper); _sut = new CompositeRequestTargetEscaper( _rfc3986Escaper, _rfc2396Escaper, _unescapedEscaper, _originalStringEscaper); }
public ClientStoreMigratorTests() { FakeFactory.Create(out _baseliner); _migrationSteps = new[] { new FakeClientStoreMigrationStep(2, () => Task.Delay(TimeSpan.FromMilliseconds(100))), new FakeClientStoreMigrationStep(4, () => Task.Delay(TimeSpan.FromMilliseconds(100))), new FakeClientStoreMigrationStep(3, () => Task.Delay(TimeSpan.FromMilliseconds(100))), }; _sut = new ClientStoreMigrator(_migrationSteps, _baseliner); }
public HttpRequestSigningHandlerTests() { FakeFactory.Create(out _requestSigner); _responseFromInner = new HttpResponseMessage(HttpStatusCode.OK); _sut = new HttpRequestSigningHandler(_requestSigner) { InnerHandler = new FakeHttpMessageHandler(_responseFromInner) }; }
public RequestTargetHeaderAppenderTests() { FakeFactory.Create(out _requestTargetEscaper); _httpRequest = new HttpRequestForSignatureString { Method = HttpMethod.Post, RequestUri = "/api/resource/id1".ToUri() }; _requestTargetEscaping = RequestTargetEscaping.RFC3986; _sut = new RequestTargetHeaderAppender(_httpRequest, _requestTargetEscaping, _requestTargetEscaper); }
public CatchAllStatusCodes() { var factory = new CustomWebApplicationFactory(); _client = factory.CreateClient(); FakeFactory.Create(out _feature); _sut.HttpContext.Features.Set(_feature); _status = "401"; _path = null; _query = null; }
public ErrorControllerTests() { FakeFactory.Create(out _logger); _sut = new ErrorController(_logger) { ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { Response = { StatusCode = 204 } } } }; }
public CompositeHeaderAppenderTests() { FakeFactory.Create( out _dateHeaderAppender, out _createdHeaderAppender, out _defaultHeaderAppender, out _expiresHeaderAppender, out _requestTargetHeaderAppender); _sut = new CompositeHeaderAppender( _defaultHeaderAppender, _requestTargetHeaderAppender, _createdHeaderAppender, _expiresHeaderAppender, _dateHeaderAppender); }
public ApplicationInfoProviderTests() { _entryAssembly = typeof(Program).Assembly; _environment = "UnitTests"; _authenticationSettings = new ImplicitFlowAuthenticationSettings { Authority = new Uri("https://webapptemplate.eu/auth"), Tenant = "M2019Tests", ClientId = "theClientId", Scopes = new[] { "scope1", "scope2" } }; FakeFactory.Create(out _httpContextAccessor); _sut = new ApplicationInfoProvider(_httpContextAccessor, _entryAssembly, _environment, _authenticationSettings); }
public CachingNonceStoreTests() { FakeFactory.Create(out _decorated); _cache = new FakeMemoryCache(); _sut = new CachingNonceStore(_decorated, _cache); _now = new DateTimeOffset( DateTimeOffset.UtcNow.Year, DateTimeOffset.UtcNow.Month, DateTimeOffset.UtcNow.Day, DateTimeOffset.UtcNow.Hour, DateTimeOffset.UtcNow.Minute, DateTimeOffset.UtcNow.Second, DateTimeOffset.UtcNow.Millisecond, TimeSpan.Zero); }
public VerificationResultCreatorTests() { FakeFactory.Create(out _claimsPrincipalFactory); _requestForVerification = new HttpRequestForVerification { Signature = new Signature { KeyId = "client1" } }; _client = new Client( "client1", "Unit test app", new HMACSignatureAlgorithm("s3cr3t", HashAlgorithmName.SHA256), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), RequestTargetEscaping.RFC3986); _sut = new VerificationResultCreator(_client, _requestForVerification, _claimsPrincipalFactory); }
public AddEncryptionSupportToClientsMigrationStepTests(MongoSetup mongoSetup) : base(mongoSetup) { FakeFactory.Create(out _stringProtectorFactory); A.CallTo(() => _stringProtectorFactory.CreateSymmetric(A <string> ._)) .Returns(new FakeStringProtector()); _settings = new MongoDbClientStoreSettings { CollectionName = "clients", SharedSecretEncryptionKey = new SharedSecretEncryptionKey("The_Big_Secret"), ConnectionString = "dummy", ClientCacheEntryExpiration = TimeSpan.Zero }; _sut = new AddEncryptionSupportToClientsMigrationStep( new MongoDatabaseClientProvider(Database), _settings, _stringProtectorFactory); }
public RequestSignerFactoryTests() { FakeFactory.Create( out _signingSettingsSanitizer, out _signatureCreator, out _authorizationHeaderParamCreator, out _signatureHeaderEnsurer, out _systemClock, out _logger, out _registeredSignerSettingsStore); _sut = new RequestSignerFactory( _signingSettingsSanitizer, _signatureCreator, _authorizationHeaderParamCreator, _signatureHeaderEnsurer, _systemClock, _registeredSignerSettingsStore, _logger); }
public Compose() { _timeOfComposing = new DateTimeOffset(2020, 2, 24, 11, 20, 14, TimeSpan.FromHours(1)); _expires = TimeSpan.FromMinutes(5); _httpRequest = new HttpRequestForSigning { Method = HttpMethod.Post, RequestUri = "http://dalion.eu/api/resource/id1" }; _headerNames = new[] { HeaderName.PredefinedHeaderNames.RequestTarget, HeaderName.PredefinedHeaderNames.Date, new HeaderName("dalion_app_id") }; _nonce = "abc123"; FakeFactory.Create(out _headerAppender); A.CallTo(() => _headerAppenderFactory.Create(_httpRequest, _timeOfComposing, _expires)) .Returns(_headerAppender); }
public SqlServerNonceStoreTests(SqlServerFixture fixture) : base(fixture) { FakeFactory.Create(out _expiredNoncesCleaner); _settings = new SqlServerNonceStoreSettings { ExpiredNoncesCleanUpInterval = TimeSpan.FromMinutes(1), ConnectionString = fixture.SqlServerConfig.GetConnectionStringForTestDatabase() }; _sut = new SqlServerNonceStore(_settings, _expiredNoncesCleaner); _now = new DateTimeOffset( DateTimeOffset.UtcNow.Year, DateTimeOffset.UtcNow.Month, DateTimeOffset.UtcNow.Day, DateTimeOffset.UtcNow.Hour, DateTimeOffset.UtcNow.Minute, DateTimeOffset.UtcNow.Second, DateTimeOffset.UtcNow.Millisecond, TimeSpan.Zero); }
public UserInfoResponseLinksCreatorTests() { FakeFactory.Create(out _hyperlinkFactory); _sut = new UserInfoResponseLinksCreator(_hyperlinkFactory); }
public CompositeSignatureHeaderEnsurerTests() { FakeFactory.Create(out _dateHeaderEnsurer, out _digestHeaderEnsurer); _sut = new CompositeSignatureHeaderEnsurer(_dateHeaderEnsurer, _digestHeaderEnsurer); }
public ReportsApplicationInfoFilterTests() { FakeFactory.Create(out _applicationInfoProvider); _sut = new ReportsApplicationInfoAttribute.ReportsApplicationInfoFilter(_applicationInfoProvider); }
public HyperlinkFactoryTests() { FakeFactory.Create(out _applicationUriResolver); _sut = new HyperlinkFactory(_applicationUriResolver); }
public NoncesFileManagerTests() { FakeFactory.Create(out _fileReader, out _fileWriter, out _dataRecordSerializer); _filePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".xml"); _sut = new NoncesFileManager(_fileReader, _fileWriter, _filePath, _dataRecordSerializer); }
public KnownAlgorithmVerificationTaskTests() { FakeFactory.Create(out _logger); _sut = new KnownAlgorithmVerificationTask(_logger); }