コード例 #1
0
        public async Task ShouldCorrectlyWorkWithDomainsForEmbedding()
        {
            await AuthenticatedClient.WithTempVideo(async clipId =>
            {
                var account = await AuthenticatedClient.GetAccountInformationAsync();
                if (account.AccountType == AccountTypeEnum.Basic || account.AccountType == AccountTypeEnum.Unknown)
                {
                    // Skip test if account type does not support domains whitelist
                    return;
                }

                await AuthenticatedClient.UpdateVideoMetadataAsync(clipId, new VideoUpdateMetadata
                {
                    EmbedPrivacy = VideoEmbedPrivacyEnum.Whitelist
                });
                var video = await AuthenticatedClient.GetVideoAsync(clipId);
                video.Privacy.EmbedPrivacy.ShouldBe(VideoEmbedPrivacyEnum.Whitelist);

                await AuthenticatedClient.AllowEmbedVideoOnDomainAsync(clipId, "example.com");
                var domains = await AuthenticatedClient.GetAllowedDomainsForEmbeddingVideoAsync(clipId);
                domains.Data.ShouldNotBeNull();
                domains.Data.Count.ShouldBe(1);
                domains.Data[0].ShouldNotBeNull();
                domains.Data[0].Domain.ShouldBe("example.com");

                await AuthenticatedClient.DisallowEmbedVideoOnDomainAsync(clipId, "example.com");
                domains = await AuthenticatedClient.GetAllowedDomainsForEmbeddingVideoAsync(clipId);
                domains.Data.ShouldNotBeNull();
                domains.Data.Count.ShouldBe(0);

                await AuthenticatedClient.UpdateVideoMetadataAsync(clipId, new VideoUpdateMetadata
                {
                    EmbedPrivacy = VideoEmbedPrivacyEnum.Public
                });
            });
        }