コード例 #1
0
        public async Task PairingRecord_Lifecycle_Async()
        {
            var key = Convert.FromBase64String(
                "LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JR0pBb0dCQUorNXVIQjJycllw" +
                "VEt4SWNGUnJxR1ZqTHRNQ2wyWHhmTVhJeEhYTURrM01jV2hxK2RtWkcvWW0KeDJuTGZq" +
                "WWJPeUduQ1BxQktxcUU5Q2tyQy9DUi9mTlgwNjJqMU1pUHJYY2RnQ0tiNzB2bmVlMFNF" +
                "T2FmNVhEQworZWFZeGdjWTYvbjBXODNrSklXMGF0czhMWmUwTW9XNXpXSTh6cnM4eDIw" +
                "UFFJK1RGU1p4QWdNQkFBRT0KLS0tLS1FTkQgUlNBIFBVQkxJQyBLRVktLS0tLQo=");

            var udid = "pairingrecord-lifecycle";
            var buid = Guid.NewGuid().ToString();

            var record = new PairingRecordGenerator().Generate(key, buid);

            using (var client = this.CreateKubernetesClient())
            {
                var store = new KubernetesPairingRecordStore(client, this.loggerFactory.CreateLogger <KubernetesPairingRecordStore>());

                // The record should not exist.
                Assert.Null(await store.ReadAsync(udid, default).ConfigureAwait(false));

                // Write the record; it can be retrieved afterwards
                await store.WriteAsync(udid, record, default).ConfigureAwait(false);

                var record2 = await store.ReadAsync(udid, default).ConfigureAwait(false);

                Assert.NotNull(record2);
                Assert.Equal(record.ToByteArray(), record2.ToByteArray());

                // Delete the record; it can no longer be retrieved afterwardss
                await store.DeleteAsync(udid, default).ConfigureAwait(false);

                Assert.Null(await store.ReadAsync(udid, default).ConfigureAwait(false));
            }
        }
コード例 #2
0
        public async Task DeleteAsync_Works_Async()
        {
            var client       = new Mock <KubernetesClient>(MockBehavior.Strict);
            var secretClient = new Mock <NamespacedKubernetesClient <V1Secret> >(MockBehavior.Strict);

            client.Setup(c => c.GetClient <V1Secret>()).Returns(secretClient.Object);

            secretClient
            .Setup(c => c.TryDeleteAsync("abc", TimeSpan.FromMinutes(1), default))
            .Returns(Task.FromResult((V1Secret)null))
            .Verifiable();

            var store = new KubernetesPairingRecordStore(client.Object, NullLogger <KubernetesPairingRecordStore> .Instance);

            await store.DeleteAsync("abc", default);

            secretClient.Verify();
        }
コード例 #3
0
        public async Task DeleteAsync_ValidatesArguments_Async()
        {
            var store = new KubernetesPairingRecordStore(Mock.Of <KubernetesClient>(), NullLogger <KubernetesPairingRecordStore> .Instance);

            await Assert.ThrowsAsync <ArgumentNullException>(() => store.DeleteAsync(null, default)).ConfigureAwait(false);
        }