1
- using System . Configuration ;
2
- using System . Web . Routing ;
3
- using NUnit . Framework ;
4
- using Umbraco . Core . Configuration ;
5
- using Umbraco . Core . IO ;
6
- using Umbraco . Tests . TestHelpers ;
7
- using System . Web . Mvc ;
8
-
9
- namespace Umbraco . Tests
10
- {
11
- [ TestFixture ]
12
- public class GlobalSettingsTests : BaseWebTest
13
- {
14
-
15
- public override void Initialize ( )
16
- {
17
- base . Initialize ( ) ;
18
- SettingsForTests . UmbracoPath = "~/umbraco" ;
19
- }
20
-
21
- public override void TearDown ( )
22
- {
23
- //ensure this is reset
24
- SystemDirectories . Root = null ;
25
- SettingsForTests . UmbracoPath = "~/umbraco" ;
26
- //reset the app config
27
- base . TearDown ( ) ;
28
-
29
- }
30
-
31
- [ Test ]
32
- public void Is_Debug_Mode ( )
33
- {
34
- Assert . That ( Umbraco . Core . Configuration . GlobalSettings . DebugMode , Is . EqualTo ( true ) ) ;
35
- }
36
-
37
- [ Ignore ]
38
- [ Test ]
39
- public void Is_Version_From_Assembly_Correct ( )
40
- {
41
- Assert . That ( UmbracoVersion . Current . ToString ( 3 ) , Is . EqualTo ( "6.0.0" ) ) ;
42
- }
43
-
44
- [ TestCase ( "~/umbraco" , "/" , "umbraco" ) ]
45
- [ TestCase ( "~/umbraco" , "/MyVirtualDir" , "umbraco" ) ]
46
- [ TestCase ( "~/customPath" , "/MyVirtualDir/" , "custompath" ) ]
47
- [ TestCase ( "~/some-wacky/nestedPath" , "/MyVirtualDir" , "some-wacky-nestedpath" ) ]
48
- [ TestCase ( "~/some-wacky/nestedPath" , "/MyVirtualDir/NestedVDir/" , "some-wacky-nestedpath" ) ]
49
- public void Umbraco_Mvc_Area ( string path , string rootPath , string outcome )
50
- {
51
- SettingsForTests . UmbracoPath = path ;
52
- SystemDirectories . Root = rootPath ;
53
- Assert . AreEqual ( outcome , Umbraco . Core . Configuration . GlobalSettings . UmbracoMvcArea ) ;
54
- }
55
-
56
- [ TestCase ( "/umbraco/umbraco.aspx" ) ]
57
- [ TestCase ( "/umbraco/editContent.aspx" ) ]
58
- [ TestCase ( "/install/default.aspx" ) ]
59
- [ TestCase ( "/install/" ) ]
60
- [ TestCase ( "/install" ) ]
61
- [ TestCase ( "/install/?installStep=asdf" ) ]
62
- [ TestCase ( "/install/test.aspx" ) ]
63
- [ TestCase ( "/config/splashes/booting.aspx" ) ]
64
- public void Is_Reserved_Path_Or_Url ( string url )
65
- {
66
- Assert . IsTrue ( Umbraco . Core . Configuration . GlobalSettings . IsReservedPathOrUrl ( url ) ) ;
67
- }
68
-
69
- [ TestCase ( "/umbraco_client/Tree/treeIcons.css" ) ]
70
- [ TestCase ( "/umbraco_client/Tree/Themes/umbraco/style.css" ) ]
71
- [ TestCase ( "/umbraco_client/scrollingmenu/style.css" ) ]
72
- [ TestCase ( "/base/somebasehandler" ) ]
73
- [ TestCase ( "/" ) ]
74
- [ TestCase ( "/home.aspx" ) ]
75
- [ TestCase ( "/umbraco-test" ) ]
76
- [ TestCase ( "/install-test" ) ]
77
- [ TestCase ( "/install.aspx" ) ]
78
- public void Is_Not_Reserved_Path_Or_Url ( string url )
79
- {
80
- Assert . IsFalse ( Umbraco . Core . Configuration . GlobalSettings . IsReservedPathOrUrl ( url ) ) ;
81
- }
82
-
83
-
84
- [ TestCase ( "/Do/Not/match" , false ) ]
85
- [ TestCase ( "/Umbraco/RenderMvcs" , false ) ]
86
- [ TestCase ( "/Umbraco/RenderMvc" , true ) ]
87
- [ TestCase ( "/Umbraco/RenderMvc/Index" , true ) ]
88
- [ TestCase ( "/Umbraco/RenderMvc/Index/1234" , true ) ]
89
- [ TestCase ( "/Umbraco/RenderMvc/Index/1234/9876" , false ) ]
90
- [ TestCase ( "/api" , true ) ]
91
- [ TestCase ( "/api/WebApiTest" , true ) ]
92
- [ TestCase ( "/api/WebApiTest/1234" , true ) ]
93
- [ TestCase ( "/api/WebApiTest/Index/1234" , false ) ]
94
- public void Is_Reserved_By_Route ( string url , bool shouldMatch )
95
- {
96
- //reset the app config, we only want to test routes not the hard coded paths
97
- Umbraco . Core . Configuration . GlobalSettings . ReservedPaths = "" ;
98
- Umbraco . Core . Configuration . GlobalSettings . ReservedUrls = "" ;
99
-
100
- var routes = new RouteCollection ( ) ;
101
-
102
- routes . MapRoute (
103
- "Umbraco_default" ,
104
- "Umbraco/RenderMvc/{action}/{id}" ,
105
- new { controller = "RenderMvc" , action = "Index" , id = UrlParameter . Optional } ) ;
106
- routes . MapRoute (
107
- "WebAPI" ,
108
- "api/{controller}/{id}" ,
109
- new { controller = "WebApiTestController" , action = "Index" , id = UrlParameter . Optional } ) ;
110
-
111
-
112
- var context = new FakeHttpContextFactory ( url ) ;
113
-
114
-
115
- Assert . AreEqual (
116
- shouldMatch ,
117
- Umbraco . Core . Configuration . GlobalSettings . IsReservedPathOrUrl ( url , context . HttpContext , routes ) ) ;
118
- }
119
- }
1
+ using System . Web . Mvc ;
2
+ using System . Web . Routing ;
3
+ using NUnit . Framework ;
4
+ using Umbraco . Core . Configuration ;
5
+ using Umbraco . Core . IO ;
6
+ using Umbraco . Tests . TestHelpers ;
7
+
8
+ namespace Umbraco . Tests . Configurations
9
+ {
10
+ [ TestFixture ]
11
+ public class GlobalSettingsTests : BaseWebTest
12
+ {
13
+
14
+ public override void Initialize ( )
15
+ {
16
+ base . Initialize ( ) ;
17
+ SettingsForTests . UmbracoPath = "~/umbraco" ;
18
+ }
19
+
20
+ public override void TearDown ( )
21
+ {
22
+ //ensure this is reset
23
+ SystemDirectories . Root = null ;
24
+ SettingsForTests . UmbracoPath = "~/umbraco" ;
25
+ //reset the app config
26
+ base . TearDown ( ) ;
27
+
28
+ }
29
+
30
+ [ Test ]
31
+ public void Is_Debug_Mode ( )
32
+ {
33
+ Assert . That ( Umbraco . Core . Configuration . GlobalSettings . DebugMode , Is . EqualTo ( true ) ) ;
34
+ }
35
+
36
+ [ Ignore ]
37
+ [ Test ]
38
+ public void Is_Version_From_Assembly_Correct ( )
39
+ {
40
+ Assert . That ( UmbracoVersion . Current . ToString ( 3 ) , Is . EqualTo ( "6.0.0" ) ) ;
41
+ }
42
+
43
+ [ TestCase ( "~/umbraco" , "/" , "umbraco" ) ]
44
+ [ TestCase ( "~/umbraco" , "/MyVirtualDir" , "umbraco" ) ]
45
+ [ TestCase ( "~/customPath" , "/MyVirtualDir/" , "custompath" ) ]
46
+ [ TestCase ( "~/some-wacky/nestedPath" , "/MyVirtualDir" , "some-wacky-nestedpath" ) ]
47
+ [ TestCase ( "~/some-wacky/nestedPath" , "/MyVirtualDir/NestedVDir/" , "some-wacky-nestedpath" ) ]
48
+ public void Umbraco_Mvc_Area ( string path , string rootPath , string outcome )
49
+ {
50
+ SettingsForTests . UmbracoPath = path ;
51
+ SystemDirectories . Root = rootPath ;
52
+ Assert . AreEqual ( outcome , Umbraco . Core . Configuration . GlobalSettings . UmbracoMvcArea ) ;
53
+ }
54
+
55
+ [ TestCase ( "/umbraco/umbraco.aspx" ) ]
56
+ [ TestCase ( "/umbraco/editContent.aspx" ) ]
57
+ [ TestCase ( "/install/default.aspx" ) ]
58
+ [ TestCase ( "/install/" ) ]
59
+ [ TestCase ( "/install" ) ]
60
+ [ TestCase ( "/install/?installStep=asdf" ) ]
61
+ [ TestCase ( "/install/test.aspx" ) ]
62
+ [ TestCase ( "/config/splashes/booting.aspx" ) ]
63
+ public void Is_Reserved_Path_Or_Url ( string url )
64
+ {
65
+ Assert . IsTrue ( Umbraco . Core . Configuration . GlobalSettings . IsReservedPathOrUrl ( url ) ) ;
66
+ }
67
+
68
+ [ TestCase ( "/umbraco_client/Tree/treeIcons.css" ) ]
69
+ [ TestCase ( "/umbraco_client/Tree/Themes/umbraco/style.css" ) ]
70
+ [ TestCase ( "/umbraco_client/scrollingmenu/style.css" ) ]
71
+ [ TestCase ( "/base/somebasehandler" ) ]
72
+ [ TestCase ( "/" ) ]
73
+ [ TestCase ( "/home.aspx" ) ]
74
+ [ TestCase ( "/umbraco-test" ) ]
75
+ [ TestCase ( "/install-test" ) ]
76
+ [ TestCase ( "/install.aspx" ) ]
77
+ public void Is_Not_Reserved_Path_Or_Url ( string url )
78
+ {
79
+ Assert . IsFalse ( Umbraco . Core . Configuration . GlobalSettings . IsReservedPathOrUrl ( url ) ) ;
80
+ }
81
+
82
+
83
+ [ TestCase ( "/Do/Not/match" , false ) ]
84
+ [ TestCase ( "/Umbraco/RenderMvcs" , false ) ]
85
+ [ TestCase ( "/Umbraco/RenderMvc" , true ) ]
86
+ [ TestCase ( "/Umbraco/RenderMvc/Index" , true ) ]
87
+ [ TestCase ( "/Umbraco/RenderMvc/Index/1234" , true ) ]
88
+ [ TestCase ( "/Umbraco/RenderMvc/Index/1234/9876" , false ) ]
89
+ [ TestCase ( "/api" , true ) ]
90
+ [ TestCase ( "/api/WebApiTest" , true ) ]
91
+ [ TestCase ( "/api/WebApiTest/1234" , true ) ]
92
+ [ TestCase ( "/api/WebApiTest/Index/1234" , false ) ]
93
+ public void Is_Reserved_By_Route ( string url , bool shouldMatch )
94
+ {
95
+ //reset the app config, we only want to test routes not the hard coded paths
96
+ Umbraco . Core . Configuration . GlobalSettings . ReservedPaths = "" ;
97
+ Umbraco . Core . Configuration . GlobalSettings . ReservedUrls = "" ;
98
+
99
+ var routes = new RouteCollection ( ) ;
100
+
101
+ routes . MapRoute (
102
+ "Umbraco_default" ,
103
+ "Umbraco/RenderMvc/{action}/{id}" ,
104
+ new { controller = "RenderMvc" , action = "Index" , id = UrlParameter . Optional } ) ;
105
+ routes . MapRoute (
106
+ "WebAPI" ,
107
+ "api/{controller}/{id}" ,
108
+ new { controller = "WebApiTestController" , action = "Index" , id = UrlParameter . Optional } ) ;
109
+
110
+
111
+ var context = new FakeHttpContextFactory ( url ) ;
112
+
113
+
114
+ Assert . AreEqual (
115
+ shouldMatch ,
116
+ Umbraco . Core . Configuration . GlobalSettings . IsReservedPathOrUrl ( url , context . HttpContext , routes ) ) ;
117
+ }
118
+ }
120
119
}
0 commit comments