Exemplo n.º 1
0
        public void ParseAsync_ReturnNullIfBodyNull()
        {
            var secretStoreFake = A.Fake <IVaultSecretStore>();
            var parserFake      = A.Fake <IRequestParser>();

            A.CallTo(() => parserFake.ReadRequestFormAsync(A <IDictionary <string, object> > ._))
            .Returns(Task.FromResult((IFormCollection)null));

            var parser = new VaultPostBodySecretParser(secretStoreFake, parserFake);

            var parseResult = parser.ParseAsync(new Dictionary <string, object>()).Result;

            parseResult.Should().BeNull();
        }
Exemplo n.º 2
0
        public void ParseAsync_ReturnNullIfClientSecretNull()
        {
            var secretStoreFake    = A.Fake <IVaultSecretStore>();
            var parserFake         = A.Fake <IRequestParser>();
            var formCollectionFake = A.Fake <IFormCollection>();

            A.CallTo(() => parserFake.ReadRequestFormAsync(A <IDictionary <string, object> > ._))
            .Returns(Task.FromResult(formCollectionFake));

            A.CallTo(() => formCollectionFake.Get("client_id")).Returns("client123");
            A.CallTo(() => formCollectionFake.Get("client_secret")).Returns(null);

            var parser = new VaultPostBodySecretParser(secretStoreFake, parserFake);

            var parseResult = parser.ParseAsync(new Dictionary <string, object>()).Result;

            parseResult.Should().BeNull();
        }
Exemplo n.º 3
0
        public void ParseAsync_ReturnsParsedSecret()
        {
            var secretStoreFake    = A.Fake <IVaultSecretStore>();
            var parserFake         = A.Fake <IRequestParser>();
            var formCollectionFake = A.Fake <IFormCollection>();

            A.CallTo(() => parserFake.ReadRequestFormAsync(A <IDictionary <string, object> > ._))
            .Returns(Task.FromResult(formCollectionFake));

            A.CallTo(() => formCollectionFake.Get("client_id")).Returns("client123");
            A.CallTo(() => formCollectionFake.Get("client_secret")).Returns("clientsecret123");

            A.CallTo(() => secretStoreFake.GetDecryptedSecret("client123", "clientsecret123"))
            .Returns(Task.FromResult("decryptedsecret123"));

            var parser = new VaultPostBodySecretParser(secretStoreFake, parserFake);

            var parseResult = parser.ParseAsync(new Dictionary <string, object>()).Result;

            parseResult.Id.Should().Be("client123");
            parseResult.Credential.Should().Be("decryptedsecret123");
            parseResult.Type.Should().Be(Constants.VaultSharedSecretType);
        }