Skip to content

Commit d0bf7ad

Browse files
committed
test: skip HTTP tests that use httpbin
1 parent 1fd9a64 commit d0bf7ad

File tree

2 files changed

+77
-68
lines changed

2 files changed

+77
-68
lines changed

test/binding_http/http_test.dart

+52-47
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ void main() {
4646
expect(customServer2.scheme, 'https');
4747
});
4848

49-
test('HTTP Security Schemes', () async {
50-
const username = 'username';
51-
const password = 'password';
52-
const token = 'thisIsTheMostAwesomeTokenEver!';
53-
54-
// TODO(JKRhb): Does not have an effect in the TD yet (and is negotiated
55-
// automatically by http_auth instead)
56-
const qop = 'auth-int';
57-
58-
const thingDescriptionJson = '''
49+
test(
50+
'HTTP Security Schemes',
51+
() async {
52+
const username = 'username';
53+
const password = 'password';
54+
const token = 'thisIsTheMostAwesomeTokenEver!';
55+
56+
// TODO(JKRhb): Does not have an effect in the TD yet (and is negotiated
57+
// automatically by http_auth instead)
58+
const qop = 'auth-int';
59+
60+
const thingDescriptionJson = '''
5961
{
6062
"@context": ["http://www.w3.org/ns/td"],
6163
"title": "Test Thing",
@@ -101,46 +103,49 @@ void main() {
101103
}
102104
''';
103105

104-
final parsedTd = ThingDescription(thingDescriptionJson);
105-
106-
final Map<String, BasicCredentials> basicCredentialsStore = {
107-
'httpbin.org': BasicCredentials(username, password),
108-
};
109-
110-
final Map<String, DigestCredentials> digestCredentialsStore = {
111-
'httpbin.org': DigestCredentials(username, password),
112-
};
113-
114-
final Map<String, BearerCredentials> bearerCredentialsStore = {
115-
'httpbin.org': BearerCredentials(token),
116-
};
106+
final parsedTd = ThingDescription(thingDescriptionJson);
117107

118-
final clientSecurityProvider = ClientSecurityProvider(
119-
basicCredentialsCallback: (uri, form, [invalidCredentials]) async {
120-
return basicCredentialsStore[uri.host];
121-
},
122-
digestCredentialsCallback: (uri, form, [invalidCredentials]) async =>
123-
digestCredentialsStore[uri.host],
124-
bearerCredentialsCallback: (uri, form, [invalidCredentials]) async =>
125-
bearerCredentialsStore[uri.host],
126-
);
127-
128-
final servient = Servient(clientSecurityProvider: clientSecurityProvider)
129-
..addClientFactory(HttpClientFactory());
130-
final wot = await servient.start();
108+
final Map<String, BasicCredentials> basicCredentialsStore = {
109+
'httpbin.org': BasicCredentials(username, password),
110+
};
131111

132-
final consumedThing = await wot.consume(parsedTd);
133-
final result = await consumedThing.readProperty('status');
134-
final value = await result.value();
135-
expect(value, {'authenticated': true, 'user': username});
112+
final Map<String, DigestCredentials> digestCredentialsStore = {
113+
'httpbin.org': DigestCredentials(username, password),
114+
};
136115

137-
// final result2 = await consumedThing.readProperty('status2');
138-
// final value2 = await result2.value();
139-
// expect(value2, {'authenticated': true, 'user': username});
116+
final Map<String, BearerCredentials> bearerCredentialsStore = {
117+
'httpbin.org': BearerCredentials(token),
118+
};
140119

141-
final result3 = await consumedThing.readProperty('status3');
142-
final value3 = await result3.value();
143-
expect(value3, {'authenticated': true, 'token': token});
144-
});
120+
final clientSecurityProvider = ClientSecurityProvider(
121+
basicCredentialsCallback: (uri, form, [invalidCredentials]) async {
122+
return basicCredentialsStore[uri.host];
123+
},
124+
digestCredentialsCallback: (uri, form, [invalidCredentials]) async =>
125+
digestCredentialsStore[uri.host],
126+
bearerCredentialsCallback: (uri, form, [invalidCredentials]) async =>
127+
bearerCredentialsStore[uri.host],
128+
);
129+
130+
final servient =
131+
Servient(clientSecurityProvider: clientSecurityProvider)
132+
..addClientFactory(HttpClientFactory());
133+
final wot = await servient.start();
134+
135+
final consumedThing = await wot.consume(parsedTd);
136+
final result = await consumedThing.readProperty('status');
137+
final value = await result.value();
138+
expect(value, {'authenticated': true, 'user': username});
139+
140+
// final result2 = await consumedThing.readProperty('status2');
141+
// final value2 = await result2.value();
142+
// expect(value2, {'authenticated': true, 'user': username});
143+
144+
final result3 = await consumedThing.readProperty('status3');
145+
final value3 = await result3.value();
146+
expect(value3, {'authenticated': true, 'token': token});
147+
},
148+
skip: true,
149+
);
145150
});
146151
}

test/core/consumed_thing_test.dart

+25-21
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,10 @@ void main() {
238238
});
239239
});
240240

241-
test('Use of URI Template Variables', () async {
242-
const thingDescriptionJson = '''
241+
test(
242+
'Use of URI Template Variables',
243+
() async {
244+
const thingDescriptionJson = '''
243245
{
244246
"@context": ["http://www.w3.org/ns/td"],
245247
"title": "Test Thing",
@@ -280,28 +282,30 @@ void main() {
280282
}
281283
''';
282284

283-
final parsedTd = ThingDescription(thingDescriptionJson);
285+
final parsedTd = ThingDescription(thingDescriptionJson);
284286

285-
final servient = Servient()..addClientFactory(HttpClientFactory());
286-
final wot = await servient.start();
287+
final servient = Servient()..addClientFactory(HttpClientFactory());
288+
final wot = await servient.start();
287289

288-
final uriVariables = {'value': 'SFRUUEJJTiBpcyBhd2Vzb21l'};
289-
final interactionOptions = InteractionOptions(uriVariables: uriVariables);
290+
final uriVariables = {'value': 'SFRUUEJJTiBpcyBhd2Vzb21l'};
291+
final interactionOptions = InteractionOptions(uriVariables: uriVariables);
290292

291-
final consumedThing = await wot.consume(parsedTd);
292-
final result =
293-
await consumedThing.readProperty('status', interactionOptions);
294-
final value = await result.value();
295-
expect(value, 'HTTPBIN is awesome');
293+
final consumedThing = await wot.consume(parsedTd);
294+
final result =
295+
await consumedThing.readProperty('status', interactionOptions);
296+
final value = await result.value();
297+
expect(value, 'HTTPBIN is awesome');
296298

297-
// status2 expects an integer instead of a String and throws an error if the
298-
// same value is provided as an input
299-
expect(
300-
consumedThing.readProperty('status2', interactionOptions),
301-
throwsA(const TypeMatcher<ValidationException>()),
302-
);
299+
// status2 expects an integer instead of a String and throws an error if
300+
// the same value is provided as an input
301+
expect(
302+
consumedThing.readProperty('status2', interactionOptions),
303+
throwsA(const TypeMatcher<ValidationException>()),
304+
);
303305

304-
await servient.shutdown();
305-
expect(servient.destroyConsumedThing(parsedTd.identifier), false);
306-
});
306+
await servient.shutdown();
307+
expect(servient.destroyConsumedThing(parsedTd.identifier), false);
308+
},
309+
skip: true, // TODO: Replace with test with local server
310+
);
307311
}

0 commit comments

Comments
 (0)