Ejemplo n.º 1
0
        public async Task KeyTypeNotSupported(string operation, string value, Func <CryptographyClient, string, Task <object> > thunk)
        {
            MockResponse keyResponse = new MockResponse(200);

            keyResponse.SetContent($@"{{""key"":{{""kid"":""{KeyId}"",""kty"":""invalid""}}}}");

            // Get the same key as above and reset the stream.
            KeyVaultKey key = new KeyVaultKey();

            key.Deserialize(keyResponse.ContentStream);
            keyResponse.ContentStream.Position = 0;

            MockResponse resultResponse = new MockResponse(200);

            resultResponse.SetContent(@$ "{{" "kid" ":" "{KeyId}" "," "value" ":{value ?? @" "" test "" "}}}");

            CryptographyClient client = CreateClient(key, new MockTransport(keyResponse, resultResponse));

            object result = await thunk(client, "invalid");

            Assert.IsNotNull(result);

            EventWrittenEventArgs e = _listener.SingleEventById(KeysEventSource.KeyTypeNotSupportedEvent);

            Assert.AreEqual(EventLevel.Verbose, e.Level);
            Assert.AreEqual("KeyTypeNotSupported", e.EventName);
            Assert.AreEqual(operation, e.GetProperty <string>("operation"));
            Assert.AreEqual("invalid", e.GetProperty <string>("keyType"));
        }