コード例 #1
0
        public async Task RemoveMediaPath_WhiteSpaceName_ReturnsBadRequest()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=+").ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
コード例 #2
0
        public async Task DeleteProfile_DoesNotExist_NotFound()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            using var getResponse = await client.DeleteAsync("/Dlna/Profiles/" + NonExistentProfile).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.NotFound, getResponse.StatusCode);
        }
コード例 #3
0
        [InlineData(1000000000)] // Too large
        public async Task BitrateTest_InvalidValue_BadRequest(int size)
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var response = await client.GetAsync("Playback/BitrateTest?size=" + size.ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
コード例 #4
0
        public async Task RemoveMediaPath_PathDoesntExist_ReturnsNotFound()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=none&path=%2Fthis%2Fpath%2Fdoesnt%2Fexist").ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
        }
コード例 #5
0
        public async Task RenameVirtualFolder_NameDoesntExist_ReturnsNotFound()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            using var postContent = new ByteArrayContent(Array.Empty <byte>());
            var response = await client.PostAsync("Library/VirtualFolders/Name?name=doesnt+exist&newName=test", postContent).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
        }
コード例 #6
0
        public async Task DeleteProfile_Valid_NoContent()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            using var getResponse = await client.DeleteAsync("/Dlna/Profiles/" + _newDeviceProfileId).ConfigureAwait(false);

            Console.WriteLine(await getResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
            Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
        }
コード例 #7
0
        public async Task ActivityLog_GetEntries_Ok()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var response = await client.GetAsync("System/ActivityLog/Entries").ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
        }
コード例 #8
0
        public async Task BitrateTest_Default_Ok()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var response = await client.GetAsync("Playback/BitrateTest").ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(MediaTypeNames.Application.Octet, response.Content.Headers.ContentType?.MediaType);
            Assert.NotNull(response.Content.Headers.ContentLength);
        }
コード例 #9
0
        public async Task BitrateTest_WithValidParam_Ok(int size)
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var response = await client.GetAsync("Playback/BitrateTest?size=" + size.ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(MediaTypeNames.Application.Octet, response.Content.Headers.ContentType?.MediaType);
            Assert.NotNull(response.Content.Headers.ContentLength);
            Assert.InRange(response.Content.Headers.ContentLength !.Value, size, long.MaxValue);
        }
コード例 #10
0
ファイル: UserControllerTests.cs プロジェクト: ypid/jellyfin
        public async Task GetUsers_Valid_Success()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            using var response = await client.GetAsync("Users").ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var users = await JsonSerializer.DeserializeAsync <UserDto[]>(
                await response.Content.ReadAsStreamAsync().ConfigureAwait(false), _jsonOpions).ConfigureAwait(false);

            Assert.Single(users);
            Assert.False(users ![0].HasConfiguredPassword);
コード例 #11
0
        public async Task CreateProfile_Valid_NoContent()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var deviceProfile = new DeviceProfile()
            {
                Name = "ThisProfileIsNew"
            };

            using var getResponse = await client.PostAsJsonAsync("/Dlna/Profiles", deviceProfile, _jsonOptions).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
        }
コード例 #12
0
        public async Task AddMediaPath_PathDoesntExist_ReturnsNotFound()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var data = new MediaPathDto()
            {
                Name = "Test",
                Path = "/this/path/doesnt/exist"
            };

            var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths", data, _jsonOptions).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
        }
コード例 #13
0
        public async Task UpdateMediaPath_WhiteSpaceName_ReturnsBadRequest()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var data = new UpdateMediaPathRequestDto()
            {
                Name     = " ",
                PathInfo = new MediaPathInfo("test")
            };

            var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths/Update", data, _jsonOptions).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
コード例 #14
0
        public async Task GetConfigurationPages_NoParams_AllConfigurationPages()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var response = await client.GetAsync("/web/ConfigurationPages").ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var res = await response.Content.ReadAsStreamAsync();

            _ = await JsonSerializer.DeserializeAsync <ConfigurationPageInfo[]>(res, _jsonOpions);

            // TODO: check content
        }
コード例 #15
0
        public async Task CreateProfile_Valid_NoContent()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var deviceProfile = new DeviceProfile()
            {
                Name = "ThisProfileIsNew"
            };

            using var content           = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(deviceProfile, _jsonOptions));
            content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
            using var getResponse       = await client.PostAsync("/Dlna/Profiles", content).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
        }
コード例 #16
0
        public async Task UpdateMediaPath_WhiteSpaceName_ReturnsBadRequest()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var data = new UpdateMediaPathRequestDto()
            {
                Name     = " ",
                PathInfo = new MediaPathInfo("test")
            };

            using var postContent           = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(data, _jsonOptions));
            postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
            var response = await client.PostAsync("Library/VirtualFolders/Paths/Update", postContent).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
コード例 #17
0
        public async Task AddMediaPath_PathDoesntExist_ReturnsNotFound()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var data = new MediaPathDto()
            {
                Name = "Test",
                Path = "/this/path/doesnt/exist"
            };

            using var postContent           = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(data, _jsonOptions));
            postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
            var response = await client.PostAsync("Library/VirtualFolders/Paths", postContent).ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
        }
コード例 #18
0
        public async Task GetConfigurationPages_True_MainMenuConfigurationPages()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            var response = await client.GetAsync("/web/ConfigurationPages?enableInMainMenu=true").ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
            Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);

            var res = await response.Content.ReadAsStreamAsync();

            var data = await JsonSerializer.DeserializeAsync <ConfigurationPageInfo[]>(res, _jsonOpions);

            Assert.Empty(data);
        }
コード例 #19
0
        public async Task GetProfileInfos_Valid_ContainsThisProfileIsNew()
        {
            var client = _factory.CreateClient();

            client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));

            using var response = await client.GetAsync("/Dlna/ProfileInfos").ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
            Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);

            var profiles = await JsonSerializer.DeserializeAsync <DeviceProfileInfo[]>(
                await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
                _jsonOptions).ConfigureAwait(false);

            var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal));

            Assert.NotNull(newProfile);
            _newDeviceProfileId = newProfile !.Id;
        }