d07ec4ad0f
The PR #10448 was doing it wrong and actually did not work. Even its unit testing was testing for a wrong output. Signed-off-by: gnattu <gnattuoc@me.com>
51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.MediaEncoding.Encoder;
|
|
using MediaBrowser.Model.Globalization;
|
|
using MediaBrowser.Model.IO;
|
|
using MediaBrowser.Model.MediaInfo;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using Moq;
|
|
using Xunit;
|
|
|
|
namespace Jellyfin.MediaEncoding.Tests.Probing
|
|
{
|
|
public class ProbeExternalSourcesTests
|
|
{
|
|
[Fact]
|
|
public void GetExtraArguments_Forwards_UserAgent()
|
|
{
|
|
var encoder = new MediaEncoder(
|
|
Mock.Of<ILogger<MediaEncoder>>(),
|
|
Mock.Of<IServerConfigurationManager>(),
|
|
Mock.Of<IFileSystem>(),
|
|
Mock.Of<IBlurayExaminer>(),
|
|
Mock.Of<ILocalizationManager>(),
|
|
new ConfigurationBuilder().Build(),
|
|
Mock.Of<IServerConfigurationManager>());
|
|
|
|
var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)";
|
|
var req = new MediaBrowser.Controller.MediaEncoding.MediaInfoRequest()
|
|
{
|
|
MediaSource = new MediaBrowser.Model.Dto.MediaSourceInfo
|
|
{
|
|
Path = "/path/to/stream",
|
|
Protocol = MediaProtocol.Http,
|
|
RequiredHttpHeaders = new Dictionary<string, string>()
|
|
{
|
|
{ "User-Agent", userAgent },
|
|
}
|
|
},
|
|
ExtractChapters = false,
|
|
MediaType = MediaBrowser.Model.Dlna.DlnaProfileType.Video,
|
|
};
|
|
|
|
var extraArg = encoder.GetExtraArguments(req);
|
|
|
|
Assert.Contains($"-user_agent \"{userAgent}\"", extraArg, StringComparison.InvariantCulture);
|
|
}
|
|
}
|
|
}
|