Example #1
0
        public void TestAddPublicKey()
        {
            var controller = new KvkController(new Mock <IKvkRepository>().Object);

            controller.AddPublicKey("123456789", "asdfghjkl");

            Assert.AreEqual("asdfghjkl", PublicKeyResolver.GetPublicKey("123456789"));
        }
Example #2
0
        /// <inheritdoc />
        public async Task <JsonObject> GetByKvkNumberAsync(string kvkNumber)
        {
            var request = new RestRequest($"api/Handelsregister/by-kvknumber/{kvkNumber}", Method.GET);

            request.AddHeader("Authorization", "Token Ax&=^tx&5EM4$5jP");

            var response = await this.Client.ExecuteTaskAsync(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var result    = JsonConvert.DeserializeObject <JsonObject>(response.Content);
                var publicKey = PublicKeyResolver.GetPublicKey(kvkNumber);

                if (!string.IsNullOrEmpty(publicKey))
                {
                    result.Add("publicKey", publicKey);
                }

                return(result);
            }

            throw new ApiException(response);
        }
Example #3
0
 public void TestReadingKeyShouldReturnKeyIfFound()
 {
     PublicKeyResolver.Add("123456789", "asdfghjkl");
     Assert.AreEqual("asdfghjkl", PublicKeyResolver.GetPublicKey("123456789"));
 }