Beispiel #1
0
        public Task GetFileWithoutVirtualPathPrefix()
        {
            // Arrange
            string virtualPath = dummyDatabaseRecordId.ToString("B");
            IVirtualImageProviderAsync target = new RemoteReaderPlugin();

            // Act / Assert
            return(Assert.ThrowsAsync <FileNotFoundException>(() => target.GetFileAsync(virtualPath, new NameValueCollection())));
        }
Beispiel #2
0
        public void DefaultConstructor()
        {
            // Arrange

            // Act
            IVirtualImageProvider target = new RemoteReaderPlugin();

            // Assert
            Assert.NotNull(target);
            Assert.IsType <RemoteReaderPlugin>(target);
        }
Beispiel #3
0
        public void FileExistsWithEmptyVirtualPath()
        {
            // Arrange
            bool expected = false;
            IVirtualImageProvider target = new RemoteReaderPlugin();

            // Act
            var actual = target.FileExists(string.Empty, null);

            // Assert
            Assert.Equal <bool>(expected, actual);
        }
Beispiel #4
0
        public void FileExistsWithNullVirtualPath()
        {
            // Arrange
            IVirtualImageProvider target = new RemoteReaderPlugin();

            // Act
            var actual = Assert.Throws <NullReferenceException>(() => target.FileExists(null, null));

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <NullReferenceException>(actual);
        }
Beispiel #5
0
        public void GetFileWithNullVirtualPath()
        {
            // Arrange
            IVirtualImageProvider target = new RemoteReaderPlugin();

            // Act
            var actual = Assert.Throws <NullReferenceException>(() => target.GetFile(null, new NameValueCollection()));

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <NullReferenceException>(actual);
        }
Beispiel #6
0
        public void GetFileWithEmptyVirtualPath()
        {
            // Arrange
            IVirtualImageProvider target = new RemoteReaderPlugin();

            // Act
            var actual = Assert.Throws <FileNotFoundException>(() => target.GetFile(string.Empty, new NameValueCollection()));

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <FileNotFoundException>(actual);
        }
Beispiel #7
0
        public void FileExistsWithoutVirtualPath()
        {
            // Arrange
            bool   expected              = false;
            string virtualPath           = dummyDatabaseRecordId.ToString("B");
            IVirtualImageProvider target = new RemoteReaderPlugin();

            // Act
            bool actual = target.FileExists(virtualPath, null);

            // Assert
            Assert.Equal <bool>(expected, actual);
        }
Beispiel #8
0
        public void GetFileWithoutVirtualPathPrefix()
        {
            // Arrange
            string virtualPath           = dummyDatabaseRecordId.ToString("B");
            IVirtualImageProvider target = new RemoteReaderPlugin();

            // Act
            var actual = Assert.Throws <FileNotFoundException>(() => target.GetFile(virtualPath, new NameValueCollection()));

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <FileNotFoundException>(actual);
        }
Beispiel #9
0
        public void GetFileNotSigned()
        {
            // Arrange
            string virtualPath           = pathPrefix + "5959854178_1c2ec6bd77_b.jpg";
            IVirtualImageProvider target = new RemoteReaderPlugin();
            var c = Config.Current;

            ((IPlugin)target).Install(c);
            var settings = this.Settings;

            // Act
            var actual = Assert.Throws <ImageProcessingException>(() => target.GetFile(virtualPath, settings));

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <ImageProcessingException>(actual);
        }
Beispiel #10
0
        public void GetFileSignedWithoutSigningKey()
        {
            // Arrange
            string virtualPath           = pathPrefix + "5959854178_1c2ec6bd77_b.jpg";
            IVirtualImageProvider target = new RemoteReaderPlugin();
            var rs = new ResizerSection("<resizer><remotereader signingKey=\"\" allowAllSignedRequests=\"true\" /></resizer>");
            var c  = new Config(rs);

            ((IPlugin)target).Install(c);
            var settings = this.Settings;

            settings["hmac"]   = "k_RU-UFkOaA";
            settings["urlb64"] = "aHR0cDovL2Zhcm03LnN0YXRpYy5mbGlja3IuY29tLzYwMjEvNTk1OTg1NDE3OF8xYzJlYzZiZDc3X2IuanBn";

            // Act
            var actual = Assert.Throws <ImageProcessingException>(() => target.GetFile(virtualPath, settings));

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <ImageProcessingException>(actual);
        }
Beispiel #11
0
        public void GetFileNotSignedAllowRemoteRequest()
        {
            // Arrange
            string             virtualPath = pathPrefix + "5959854178_1c2ec6bd77_b.jpg";
            var                c           = new Config();
            RemoteReaderPlugin target      = new RemoteReaderPlugin();

            target.Install(c);
            target.AllowRemoteRequest += delegate(object sender, RemoteRequestEventArgs args) {
                args.DenyRequest = false;
            };
            var settings = this.Settings;

            // Act
            var actual = ((IVirtualImageProvider)target).GetFile(virtualPath, settings);

            // Assert
            Assert.NotNull(actual);
            Assert.IsAssignableFrom <IVirtualFile>(actual);
            Assert.Equal <string>(virtualPath, actual.VirtualPath);
        }
Beispiel #12
0
        public static Config GetConfig()
        {
            Config c = new Config();
            //c.Pipeline.s
            WatermarkPlugin w = new ImageResizer.Plugins.Watermark.WatermarkPlugin();

            w.align              = System.Drawing.ContentAlignment.BottomLeft;
            w.hideIfTooSmall     = false;
            w.keepAspectRatio    = true;
            w.valuesPercentages  = true;
            w.watermarkDir       = "~/"; //Where the watermark plugin looks for the image specified in the querystring ?watermark=file.png
            w.bottomRightPadding = new System.Drawing.SizeF(0, 0);
            w.topLeftPadding     = new System.Drawing.SizeF(0, 0);
            w.watermarkSize      = new System.Drawing.SizeF(1, 1); //The desired size of the watermark, maximum dimensions (aspect ratio maintained if keepAspectRatio = true)
            //Install the plugin
            w.Install(c);

            new Gradient().Install(c);
            new PrettyGifs().Install(c);
            new AnimatedGifs().Install(c);
            new AdvancedFilters().Install(c);
            RemoteReaderPlugin rrp = new RemoteReaderPlugin(); rrp.Install(c);

            rrp.AllowRemoteRequest += delegate(object sender, RemoteRequestEventArgs args) {
                args.DenyRequest = false;
            }; //Doesn't support non-ASP.NET usage yet.

            new SeamCarvingPlugin().Install(c);
            new SimpleFilters().Install(c);
            new DropShadow().Install(c);
            new WhitespaceTrimmerPlugin().Install(c);
            new VirtualFolder("/images", "..\\..\\..\\Samples\\Images", false).Install(c);

            new ImageResizer.Plugins.SourceMemCache.SourceMemCachePlugin().Install(c);

            //s3reader
            //sqlreader

            return(c);
        }
Beispiel #13
0
        public void OpenInvalidId()
        {
            // Arrange
            string virtualPath           = pathPrefix + "NoFileExists.jpg";
            IVirtualImageProvider reader = new RemoteReaderPlugin();
            var rs = new ResizerSection("<resizer><remotereader signingKey=\"ag383ht23sag#laf#lafF#oyfafqewt;2twfqw\" allowAllSignedRequests=\"true\" /></resizer>");
            var c  = new Config(rs);

            ((RemoteReaderPlugin)reader).Install(c);
            var settings = this.Settings;

            settings["hmac"]   = "1uiNwp7bpsk";
            settings["urlb64"] = "aHR0cDovL2Zhcm03LnN0YXRpYy5mbGlja3IuY29tLzYwMjEvTm9GaWxlRXhpc3RzLmpwZw";
            var target = reader.GetFile(virtualPath, settings);

            // Act
            var actual = Assert.Throws <FileNotFoundException>(() => target.Open());

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <FileNotFoundException>(actual);
        }
Beispiel #14
0
        public void GetFileSigned()
        {
            // Arrange
            string virtualPath           = pathPrefix + "5959854178_1c2ec6bd77_b.jpg";
            IVirtualImageProvider target = new RemoteReaderPlugin();
            var rs = new ResizerSection("<resizer><remotereader signingKey=\"ag383ht23sag#laf#lafF#oyfafqewt;2twfqw\" allowAllSignedRequests=\"true\" /></resizer>");
            var c  = new Config(rs);

            ((IPlugin)target).Install(c);
            var settings = this.Settings;

            settings["hmac"]   = "k_RU-UFkOaA";
            settings["urlb64"] = "aHR0cDovL2Zhcm03LnN0YXRpYy5mbGlja3IuY29tLzYwMjEvNTk1OTg1NDE3OF8xYzJlYzZiZDc3X2IuanBn";

            // Act
            var actual = target.GetFile(virtualPath, settings);

            // Assert
            Assert.NotNull(actual);
            Assert.IsAssignableFrom <IVirtualFile>(actual);
            Assert.Equal <string>(virtualPath, actual.VirtualPath);
        }
Beispiel #15
0
        public void GetFileNotSignedWhitelisted()
        {
            // Arrange
            string             virtualPath = pathPrefix + "5959854178_1c2ec6bd77_b.jpg";
            var                rs          = new ResizerSection("<resizer><remotereader signingKey=\"ag383ht23sag#laf#lafF#oyfafqewt;2twfqw\" allowAllSignedRequests=\"false\"><allow domain=\"farm7.static.flickr.com\" /></remotereader></resizer>");
            var                c           = new Config(rs);
            RemoteReaderPlugin target      = new RemoteReaderPlugin();

            target.Install(c);
            target.AllowRemoteRequest += delegate(object sender, RemoteRequestEventArgs args) {
                args.DenyRequest = false;
            };
            var settings = this.Settings;

            // Act
            var actual = ((IVirtualImageProvider)target).GetFile(virtualPath, settings);

            // Assert
            Assert.NotNull(actual);
            Assert.IsAssignableFrom <IVirtualFile>(actual);
            Assert.Equal <string>(virtualPath, actual.VirtualPath);
        }