Ejemplo n.º 1
0
        public async Task GetSecretLookupTable_Throws_IfNoSecrets()
        {
            // Arrange
            ReceiverMock mock = new ReceiverMock();
            _settings["MS_WebHookReceiverSecret_Pusher"] = "         ";

            // Act
            HttpResponseException ex = Assert.Throws<HttpResponseException>(() => mock.GetSecretLookupTable(_postRequest));

            // Assert
            HttpError error = await ex.Response.Content.ReadAsAsync<HttpError>();
            Assert.Equal("Did not find any applications settings of the form 'MS_WebHookReceiverSecret_Pusher'. To receive WebHooks from the 'PusherWebHookReceiver' receiver, please add corresponding applications settings.", error.Message);
        }
Ejemplo n.º 2
0
        public void GetSecretLookupTable_ReturnsSameInstance()
        {
            // Arrange
            ReceiverMock mock = new ReceiverMock();

            // Act
            IDictionary<string, string> actual1 = mock.GetSecretLookupTable(_postRequest);
            IDictionary<string, string> actual2 = mock.GetSecretLookupTable(_postRequest);

            // Assert
            Assert.Same(actual1, actual2);
        }
Ejemplo n.º 3
0
        public async Task GetSecretLookupTable_Throws_IfInvalidSecret(string invalid)
        {
            // Arrange
            ReceiverMock mock = new ReceiverMock();
            _settings["MS_WebHookReceiverSecret_Pusher"] = invalid;

            // Act
            HttpResponseException ex = Assert.Throws<HttpResponseException>(() => mock.GetSecretLookupTable(_postRequest));

            // Assert
            HttpError error = await ex.Response.Content.ReadAsAsync<HttpError>();
            Assert.Equal("The application setting 'MS_WebHookReceiverSecret_Pusher' must have a comma separated list of one or more values of the form '<appKey>_<appSecret>'.", error.Message);
        }
Ejemplo n.º 4
0
        public void GetSecretLookupTable_BuildsLookupTable(string secret, IDictionary<string, string> expected)
        {
            // Arrange
            ReceiverMock mock = new ReceiverMock();
            _settings["MS_WebHookReceiverSecret_Pusher"] = secret;

            // Act
            IDictionary<string, string> actual = mock.GetSecretLookupTable(_postRequest);

            // Assert
            Assert.Equal(expected, actual);
        }