コード例 #1
0
        public async Task PutKey_NotAFunction_ReturnsNotFound()
        {
            var key = new Key("key2", "secret2");

            var result = (StatusCodeResult)(await _testController.Put("DNE", key.Name, key));

            Assert.Equal(StatusCodes.Status404NotFound, result.StatusCode);
        }
コード例 #2
0
        public async Task PutKey_NotAFunction_ReturnsNotFound()
        {
            var key = new Key("key2", "secret2");

            var result = (StatusCodeResult)(await _testController.Put("DNE", key.Name, key));

            Assert.Equal(StatusCodes.Status404NotFound, result.StatusCode);

            _functionsSyncManagerMock.Verify(p => p.TrySyncTriggersAsync(false), Times.Never);
        }
コード例 #3
0
        public async Task PutKey_FunctionInError_Succeeds()
        {
            _testController.Request = new HttpRequestMessage(HttpMethod.Get, "https://local/admin/functions/keys/key2");

            var key = new Key("key2", "secret2");
            var keyOperationResult = new KeyOperationResult(key.Value, OperationResult.Updated);

            _secretsManagerMock.Setup(p => p.AddOrUpdateFunctionSecretAsync(key.Name, key.Value, "ErrorFunction", ScriptSecretsType.Function)).ReturnsAsync(keyOperationResult);

            var result  = (OkNegotiatedContentResult <ApiModel>)(await _testController.Put("ErrorFunction", key.Name, key));
            var content = (JObject)result.Content;

            Assert.Equal("key2", content["name"]);
            Assert.Equal("secret2", content["value"]);
        }
コード例 #4
0
        public async Task PutKey_FunctionInError_Succeeds()
        {
            SetHttpContext();

            var key = new Key("key2", "secret2");
            var keyOperationResult = new KeyOperationResult(key.Value, OperationResult.Updated);

            _secretsManagerMock.Setup(p => p.AddOrUpdateFunctionSecretAsync(key.Name, key.Value, "ErrorFunction", ScriptSecretsType.Function)).ReturnsAsync(keyOperationResult);

            ObjectResult result = (ObjectResult)await _testController.Put("ErrorFunction", key.Name, key);

            var content = (JObject)result.Value;

            Assert.Equal("key2", content["name"]);
            Assert.Equal("secret2", content["value"]);
        }