OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Pub-specific scheduled_test descriptors. | 5 /// Pub-specific scheduled_test descriptors. |
6 library descriptor; | 6 library descriptor; |
7 | 7 |
8 import 'package:oauth2/oauth2.dart' as oauth2; | 8 import 'package:oauth2/oauth2.dart' as oauth2; |
9 import 'package:scheduled_test/scheduled_server.dart'; | 9 import 'package:scheduled_test/scheduled_server.dart'; |
10 import 'package:scheduled_test/descriptor.dart'; | 10 import 'package:scheduled_test/descriptor.dart'; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 }); | 138 }); |
139 | 139 |
140 return hostedCache(contents); | 140 return hostedCache(contents); |
141 } | 141 } |
142 | 142 |
143 /// Describes the main cache directory containing cached hosted packages | 143 /// Describes the main cache directory containing cached hosted packages |
144 /// downloaded from the mock package server. | 144 /// downloaded from the mock package server. |
145 Descriptor hostedCache(Iterable<Descriptor> contents) { | 145 Descriptor hostedCache(Iterable<Descriptor> contents) { |
146 return dir(cachePath, [ | 146 return dir(cachePath, [ |
147 dir('hosted', [ | 147 dir('hosted', [ |
148 async(port.then((p) => dir('127.0.0.1%58$p', contents))) | 148 async(port.then((p) => dir('localhost%58$p', contents))) |
149 ]) | 149 ]) |
150 ]); | 150 ]); |
151 } | 151 } |
152 | 152 |
153 /// Describes the file in the system cache that contains the client's OAuth2 | 153 /// Describes the file in the system cache that contains the client's OAuth2 |
154 /// credentials. The URL "/token" on [server] will be used as the token | 154 /// credentials. The URL "/token" on [server] will be used as the token |
155 /// endpoint for refreshing the access token. | 155 /// endpoint for refreshing the access token. |
156 Descriptor credentialsFile( | 156 Descriptor credentialsFile( |
157 ScheduledServer server, | 157 ScheduledServer server, |
158 String accessToken, | 158 String accessToken, |
159 {String refreshToken, | 159 {String refreshToken, |
160 DateTime expiration}) { | 160 DateTime expiration}) { |
161 return async(server.url.then((url) { | 161 return async(server.url.then((url) { |
162 return dir(cachePath, [ | 162 return dir(cachePath, [ |
163 file('credentials.json', new oauth2.Credentials( | 163 file('credentials.json', new oauth2.Credentials( |
164 accessToken, | 164 accessToken, |
165 refreshToken, | 165 refreshToken, |
166 url.resolve('/token'), | 166 url.resolve('/token'), |
167 ['https://www.googleapis.com/auth/userinfo.email'], | 167 ['https://www.googleapis.com/auth/userinfo.email'], |
168 expiration).toJson()) | 168 expiration).toJson()) |
169 ]); | 169 ]); |
170 })); | 170 })); |
171 } | 171 } |
172 | 172 |
173 /// Describes the application directory, containing only a pubspec specifying | 173 /// Describes the application directory, containing only a pubspec specifying |
174 /// the given [dependencies]. | 174 /// the given [dependencies]. |
175 DirectoryDescriptor appDir([Map dependencies]) => | 175 DirectoryDescriptor appDir([Map dependencies]) => |
176 dir(appPath, [appPubspec(dependencies)]); | 176 dir(appPath, [appPubspec(dependencies)]); |
OLD | NEW |