public virtual void TestNoLogs() { FileUtil.FullyDelete(new FilePath("target/logs")); Configuration configuration = GetConfiguration(); FilePath f = new FilePath("target/logs/logs/application_0_0001/container_0_0001_01_000001" ); if (!f.Exists()) { NUnit.Framework.Assert.IsTrue(f.Mkdirs()); } WriteLog(configuration, "admin"); AggregatedLogsBlockForTest aggregatedBlock = GetAggregatedLogsBlockForTest(configuration , "admin", "container_0_0001_01_000001"); ByteArrayOutputStream data = new ByteArrayOutputStream(); PrintWriter printWriter = new PrintWriter(data); HtmlBlock html = new HtmlBlockForTest(); HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false); aggregatedBlock.Render(block); block.GetWriter().Flush(); string @out = data.ToString(); NUnit.Framework.Assert.IsTrue(@out.Contains("No logs available for container container_0_0001_01_000001" )); }
public virtual void TestBadLogs() { FileUtil.FullyDelete(new FilePath("target/logs")); Configuration configuration = GetConfiguration(); WriteLogs("target/logs/logs/application_0_0001/container_0_0001_01_000001"); WriteLog(configuration, "owner"); AggregatedLogsBlockForTest aggregatedBlock = GetAggregatedLogsBlockForTest(configuration , "admin", "container_0_0001_01_000001"); ByteArrayOutputStream data = new ByteArrayOutputStream(); PrintWriter printWriter = new PrintWriter(data); HtmlBlock html = new HtmlBlockForTest(); HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false); aggregatedBlock.Render(block); block.GetWriter().Flush(); string @out = data.ToString(); NUnit.Framework.Assert.IsTrue(@out.Contains("Logs not available for entity. Aggregation may not be complete, Check back later or try the nodemanager at localhost:1234" )); }
public virtual void TestAccessDenied() { FileUtil.FullyDelete(new FilePath("target/logs")); Configuration configuration = GetConfiguration(); WriteLogs("target/logs/logs/application_0_0001/container_0_0001_01_000001"); WriteLog(configuration, "owner"); AggregatedLogsBlockForTest aggregatedBlock = GetAggregatedLogsBlockForTest(configuration , "owner", "container_0_0001_01_000001"); ByteArrayOutputStream data = new ByteArrayOutputStream(); PrintWriter printWriter = new PrintWriter(data); HtmlBlock html = new HtmlBlockForTest(); HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false); aggregatedBlock.Render(block); block.GetWriter().Flush(); string @out = data.ToString(); NUnit.Framework.Assert.IsTrue(@out.Contains("User [owner] is not authorized to view the logs for entity" )); }