Skip to content

Commit dc73eac

Browse files
committed
chore!: do not expose the TD ID via AugmentedForms
1 parent b656efe commit dc73eac

File tree

6 files changed

+31
-20
lines changed

6 files changed

+31
-20
lines changed

example/complex_example.dart

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,23 @@ const thingDescriptionJson = {
7575
},
7676
};
7777

78-
final Map<String, BasicCredentials> basicCredentials = {
79-
"urn:test": const BasicCredentials("username", "password"),
78+
final Map<Uri, BasicCredentials> basicCredentials = {
79+
Uri.parse("https://httpbin.org"):
80+
const BasicCredentials("username", "password"),
8081
};
8182

8283
Future<BasicCredentials?> basicCredentialsCallback(
8384
Uri uri,
84-
AugmentedForm? form, [
85+
AugmentedForm? form,
8586
BasicCredentials? invalidCredentials,
86-
]) async {
87-
final id = form?.tdIdentifier;
87+
) async {
88+
final href = Uri(
89+
scheme: uri.scheme,
90+
host: uri.host,
91+
port: uri.port,
92+
);
8893

89-
return basicCredentials[id];
94+
return basicCredentials[href];
9095
}
9196

9297
Future<void> main() async {

example/http_basic_authentication.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const thingDescriptionJson = {
3737

3838
const basicCredentials = BasicCredentials("username", "password");
3939

40-
final Map<String, BasicCredentials> basicCredentialsMap = {
41-
"urn:test": basicCredentials,
40+
final Map<Uri, BasicCredentials> basicCredentialsMap = {
41+
Uri.parse("https://httpbin.org"): basicCredentials,
4242
};
4343

4444
Future<BasicCredentials?> basicCredentialsCallback(
@@ -50,9 +50,13 @@ Future<BasicCredentials?> basicCredentialsCallback(
5050
return basicCredentials;
5151
}
5252

53-
final id = form.tdIdentifier;
53+
final href = Uri(
54+
scheme: uri.scheme,
55+
host: uri.host,
56+
port: uri.port,
57+
);
5458

55-
return basicCredentialsMap[id];
59+
return basicCredentialsMap[href];
5660
}
5761

5862
/// Illustrates the usage of both the basic and the automatic security scheme,

example/mqtt_example.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,25 @@ const thingDescriptionJson = {
4545
},
4646
};
4747

48-
final Map<String, BasicCredentials> basicCredentials = {
49-
"urn:test": const BasicCredentials("rw", "readwrite"),
48+
final Map<Uri, BasicCredentials> basicCredentials = {
49+
Uri.parse("mqtt://test.mosquitto.org:1884"): const BasicCredentials(
50+
"rw",
51+
"readwrite",
52+
),
5053
};
5154

5255
Future<BasicCredentials?> basicCredentialsCallback(
5356
Uri uri,
5457
AugmentedForm? form, [
5558
BasicCredentials? invalidCredentials,
5659
]) async {
57-
final id = form?.tdIdentifier;
60+
final href = Uri(
61+
scheme: uri.scheme,
62+
host: uri.host,
63+
port: uri.port,
64+
);
5865

59-
return basicCredentials[id];
66+
return basicCredentials[href];
6067
}
6168

6269
Future<void> main(List<String> args) async {

lib/src/binding_mqtt/mqtt_extensions.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ extension MqttFormExtension on AugmentedForm {
140140
if (qosValue != null) {
141141
throw FormatException(
142142
"Encountered unknown QoS value $qosValue. "
143-
"in form with href $href of Thing Description with Identifier "
144-
"$tdIdentifier.",
143+
"in form with resolved href $resolvedHref.",
145144
);
146145
}
147146

lib/src/core/implementation/augmented_form.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ final class AugmentedForm implements Form {
3131

3232
final Map<String, Object>? _userProvidedUriVariables;
3333

34-
/// The identifier of the [_thingDescription] associated with this form.
35-
String get tdIdentifier => _thingDescription.identifier;
36-
3734
@override
3835
Map<String, dynamic> get additionalFields => _form.additionalFields;
3936

test/core/augmented_form_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ void main() {
6363
expect(augmentedForm.href, Uri.parse(href));
6464
expect(augmentedForm.security, ["nosec_sc"]);
6565
expect(augmentedForm.securityDefinitions.first, isA<NoSecurityScheme>());
66-
expect(augmentedForm.tdIdentifier, id);
6766
expect(
6867
augmentedForm.additionalResponses?.first.contentType,
6968
"application/json",

0 commit comments

Comments
 (0)