From d0bf7adf989af96a1f1e86357b984b51f3047db1 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Fri, 21 Jul 2023 16:44:52 +0200 Subject: [PATCH] test: skip HTTP tests that use httpbin --- test/binding_http/http_test.dart | 99 ++++++++++++++++-------------- test/core/consumed_thing_test.dart | 46 +++++++------- 2 files changed, 77 insertions(+), 68 deletions(-) diff --git a/test/binding_http/http_test.dart b/test/binding_http/http_test.dart index efc91e65..38d12d66 100644 --- a/test/binding_http/http_test.dart +++ b/test/binding_http/http_test.dart @@ -46,16 +46,18 @@ void main() { expect(customServer2.scheme, 'https'); }); - test('HTTP Security Schemes', () async { - const username = 'username'; - const password = 'password'; - const token = 'thisIsTheMostAwesomeTokenEver!'; - - // TODO(JKRhb): Does not have an effect in the TD yet (and is negotiated - // automatically by http_auth instead) - const qop = 'auth-int'; - - const thingDescriptionJson = ''' + test( + 'HTTP Security Schemes', + () async { + const username = 'username'; + const password = 'password'; + const token = 'thisIsTheMostAwesomeTokenEver!'; + + // TODO(JKRhb): Does not have an effect in the TD yet (and is negotiated + // automatically by http_auth instead) + const qop = 'auth-int'; + + const thingDescriptionJson = ''' { "@context": ["http://www.w3.org/ns/td"], "title": "Test Thing", @@ -101,46 +103,49 @@ void main() { } '''; - final parsedTd = ThingDescription(thingDescriptionJson); - - final Map basicCredentialsStore = { - 'httpbin.org': BasicCredentials(username, password), - }; - - final Map digestCredentialsStore = { - 'httpbin.org': DigestCredentials(username, password), - }; - - final Map bearerCredentialsStore = { - 'httpbin.org': BearerCredentials(token), - }; + final parsedTd = ThingDescription(thingDescriptionJson); - final clientSecurityProvider = ClientSecurityProvider( - basicCredentialsCallback: (uri, form, [invalidCredentials]) async { - return basicCredentialsStore[uri.host]; - }, - digestCredentialsCallback: (uri, form, [invalidCredentials]) async => - digestCredentialsStore[uri.host], - bearerCredentialsCallback: (uri, form, [invalidCredentials]) async => - bearerCredentialsStore[uri.host], - ); - - final servient = Servient(clientSecurityProvider: clientSecurityProvider) - ..addClientFactory(HttpClientFactory()); - final wot = await servient.start(); + final Map basicCredentialsStore = { + 'httpbin.org': BasicCredentials(username, password), + }; - final consumedThing = await wot.consume(parsedTd); - final result = await consumedThing.readProperty('status'); - final value = await result.value(); - expect(value, {'authenticated': true, 'user': username}); + final Map digestCredentialsStore = { + 'httpbin.org': DigestCredentials(username, password), + }; - // final result2 = await consumedThing.readProperty('status2'); - // final value2 = await result2.value(); - // expect(value2, {'authenticated': true, 'user': username}); + final Map bearerCredentialsStore = { + 'httpbin.org': BearerCredentials(token), + }; - final result3 = await consumedThing.readProperty('status3'); - final value3 = await result3.value(); - expect(value3, {'authenticated': true, 'token': token}); - }); + final clientSecurityProvider = ClientSecurityProvider( + basicCredentialsCallback: (uri, form, [invalidCredentials]) async { + return basicCredentialsStore[uri.host]; + }, + digestCredentialsCallback: (uri, form, [invalidCredentials]) async => + digestCredentialsStore[uri.host], + bearerCredentialsCallback: (uri, form, [invalidCredentials]) async => + bearerCredentialsStore[uri.host], + ); + + final servient = + Servient(clientSecurityProvider: clientSecurityProvider) + ..addClientFactory(HttpClientFactory()); + final wot = await servient.start(); + + final consumedThing = await wot.consume(parsedTd); + final result = await consumedThing.readProperty('status'); + final value = await result.value(); + expect(value, {'authenticated': true, 'user': username}); + + // final result2 = await consumedThing.readProperty('status2'); + // final value2 = await result2.value(); + // expect(value2, {'authenticated': true, 'user': username}); + + final result3 = await consumedThing.readProperty('status3'); + final value3 = await result3.value(); + expect(value3, {'authenticated': true, 'token': token}); + }, + skip: true, + ); }); } diff --git a/test/core/consumed_thing_test.dart b/test/core/consumed_thing_test.dart index df6ef20b..75e4ccc7 100644 --- a/test/core/consumed_thing_test.dart +++ b/test/core/consumed_thing_test.dart @@ -238,8 +238,10 @@ void main() { }); }); - test('Use of URI Template Variables', () async { - const thingDescriptionJson = ''' + test( + 'Use of URI Template Variables', + () async { + const thingDescriptionJson = ''' { "@context": ["http://www.w3.org/ns/td"], "title": "Test Thing", @@ -280,28 +282,30 @@ void main() { } '''; - final parsedTd = ThingDescription(thingDescriptionJson); + final parsedTd = ThingDescription(thingDescriptionJson); - final servient = Servient()..addClientFactory(HttpClientFactory()); - final wot = await servient.start(); + final servient = Servient()..addClientFactory(HttpClientFactory()); + final wot = await servient.start(); - final uriVariables = {'value': 'SFRUUEJJTiBpcyBhd2Vzb21l'}; - final interactionOptions = InteractionOptions(uriVariables: uriVariables); + final uriVariables = {'value': 'SFRUUEJJTiBpcyBhd2Vzb21l'}; + final interactionOptions = InteractionOptions(uriVariables: uriVariables); - final consumedThing = await wot.consume(parsedTd); - final result = - await consumedThing.readProperty('status', interactionOptions); - final value = await result.value(); - expect(value, 'HTTPBIN is awesome'); + final consumedThing = await wot.consume(parsedTd); + final result = + await consumedThing.readProperty('status', interactionOptions); + final value = await result.value(); + expect(value, 'HTTPBIN is awesome'); - // status2 expects an integer instead of a String and throws an error if the - // same value is provided as an input - expect( - consumedThing.readProperty('status2', interactionOptions), - throwsA(const TypeMatcher()), - ); + // status2 expects an integer instead of a String and throws an error if + // the same value is provided as an input + expect( + consumedThing.readProperty('status2', interactionOptions), + throwsA(const TypeMatcher()), + ); - await servient.shutdown(); - expect(servient.destroyConsumedThing(parsedTd.identifier), false); - }); + await servient.shutdown(); + expect(servient.destroyConsumedThing(parsedTd.identifier), false); + }, + skip: true, // TODO: Replace with test with local server + ); }