Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: mojo/public/dart/third_party/shelf_static/test/symbolic_link_test.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library shelf_static.symbolic_link_test;
6
7 import 'dart:io';
8 import 'package:path/path.dart' as p;
9 import 'package:scheduled_test/descriptor.dart' as d;
10 import 'package:scheduled_test/scheduled_test.dart';
11
12 import 'package:shelf_static/shelf_static.dart';
13 import 'test_util.dart';
14
15 void main() {
16 setUp(() {
17 var tempDir;
18 schedule(() {
19 return Directory.systemTemp.createTemp('shelf_static-test-').then((dir) {
20 tempDir = dir;
21 d.defaultRoot = tempDir.path;
22 });
23 });
24
25 d.dir('originals', [d.file('index.html', '<html></html>'),]).create();
26
27 d.dir('alt_root').create();
28
29 schedule(() {
30 var originalsDir = p.join(d.defaultRoot, 'originals');
31 var originalsIndex = p.join(originalsDir, 'index.html');
32
33 new Link(p.join(d.defaultRoot, 'link_index.html'))
34 .createSync(originalsIndex);
35
36 new Link(p.join(d.defaultRoot, 'link_dir')).createSync(originalsDir);
37
38 new Link(p.join(d.defaultRoot, 'alt_root', 'link_index.html'))
39 .createSync(originalsIndex);
40
41 new Link(p.join(d.defaultRoot, 'alt_root', 'link_dir'))
42 .createSync(originalsDir);
43 });
44
45 currentSchedule.onComplete.schedule(() {
46 d.defaultRoot = null;
47 return tempDir.delete(recursive: true);
48 });
49 });
50
51 group('access outside of root disabled', () {
52 test('access real file', () {
53 schedule(() {
54 var handler = createStaticHandler(d.defaultRoot);
55
56 return makeRequest(handler, '/originals/index.html').then((response) {
57 expect(response.statusCode, HttpStatus.OK);
58 expect(response.contentLength, 13);
59 expect(response.readAsString(), completion('<html></html>'));
60 });
61 });
62 });
63
64 group('links under root dir', () {
65 test('access sym linked file in real dir', () {
66 schedule(() {
67 var handler = createStaticHandler(d.defaultRoot);
68
69 return makeRequest(handler, '/link_index.html').then((response) {
70 expect(response.statusCode, HttpStatus.OK);
71 expect(response.contentLength, 13);
72 expect(response.readAsString(), completion('<html></html>'));
73 });
74 });
75 });
76
77 test('access file in sym linked dir', () {
78 schedule(() {
79 var handler = createStaticHandler(d.defaultRoot);
80
81 return makeRequest(handler, '/link_dir/index.html').then((response) {
82 expect(response.statusCode, HttpStatus.OK);
83 expect(response.contentLength, 13);
84 expect(response.readAsString(), completion('<html></html>'));
85 });
86 });
87 });
88 });
89
90 group('links not under root dir', () {
91 test('access sym linked file in real dir', () {
92 schedule(() {
93 var handler = createStaticHandler(p.join(d.defaultRoot, 'alt_root'));
94
95 return makeRequest(handler, '/link_index.html').then((response) {
96 expect(response.statusCode, HttpStatus.NOT_FOUND);
97 });
98 });
99 });
100
101 test('access file in sym linked dir', () {
102 schedule(() {
103 var handler = createStaticHandler(p.join(d.defaultRoot, 'alt_root'));
104
105 return makeRequest(handler, '/link_dir/index.html').then((response) {
106 expect(response.statusCode, HttpStatus.NOT_FOUND);
107 });
108 });
109 });
110 });
111 });
112
113 group('access outside of root enabled', () {
114 test('access real file', () {
115 schedule(() {
116 var handler =
117 createStaticHandler(d.defaultRoot, serveFilesOutsidePath: true);
118
119 return makeRequest(handler, '/originals/index.html').then((response) {
120 expect(response.statusCode, HttpStatus.OK);
121 expect(response.contentLength, 13);
122 expect(response.readAsString(), completion('<html></html>'));
123 });
124 });
125 });
126
127 group('links under root dir', () {
128 test('access sym linked file in real dir', () {
129 schedule(() {
130 var handler =
131 createStaticHandler(d.defaultRoot, serveFilesOutsidePath: true);
132
133 return makeRequest(handler, '/link_index.html').then((response) {
134 expect(response.statusCode, HttpStatus.OK);
135 expect(response.contentLength, 13);
136 expect(response.readAsString(), completion('<html></html>'));
137 });
138 });
139 });
140
141 test('access file in sym linked dir', () {
142 schedule(() {
143 var handler =
144 createStaticHandler(d.defaultRoot, serveFilesOutsidePath: true);
145
146 return makeRequest(handler, '/link_dir/index.html').then((response) {
147 expect(response.statusCode, HttpStatus.OK);
148 expect(response.contentLength, 13);
149 expect(response.readAsString(), completion('<html></html>'));
150 });
151 });
152 });
153 });
154
155 group('links not under root dir', () {
156 test('access sym linked file in real dir', () {
157 schedule(() {
158 var handler = createStaticHandler(p.join(d.defaultRoot, 'alt_root'),
159 serveFilesOutsidePath: true);
160
161 return makeRequest(handler, '/link_index.html').then((response) {
162 expect(response.statusCode, HttpStatus.OK);
163 expect(response.contentLength, 13);
164 expect(response.readAsString(), completion('<html></html>'));
165 });
166 });
167 });
168
169 test('access file in sym linked dir', () {
170 schedule(() {
171 var handler = createStaticHandler(p.join(d.defaultRoot, 'alt_root'),
172 serveFilesOutsidePath: true);
173
174 return makeRequest(handler, '/link_dir/index.html').then((response) {
175 expect(response.statusCode, HttpStatus.OK);
176 expect(response.contentLength, 13);
177 expect(response.readAsString(), completion('<html></html>'));
178 });
179 });
180 });
181 });
182 });
183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698