Skip to content

Commit

Permalink
Issue 544 (#545)
Browse files Browse the repository at this point in the history
* Issue 544

* Issue 544
  • Loading branch information
shamblett authored Jul 6, 2024
1 parent 4e47e92 commit 9327a4b
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 24 deletions.
20 changes: 14 additions & 6 deletions example/aws_iot_cognito.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:mqtt_client/mqtt_server_client.dart';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:http/http.dart';
//HTTP import 'package:http/http.dart';
import 'package:sigv4/sigv4.dart';

/// An example of connecting to the AWS IoT Core MQTT broker and publishing to a devices topic.
Expand All @@ -22,6 +22,10 @@ import 'package:sigv4/sigv4.dart';
/// https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html, please read this
/// before setting up and running this example.
/// Note the dependency on the http package has been removed from the client, as such lines below
/// depending on this are commented out. If you wish to run this example please re add package http
/// at version 1.2.1 to the pubspec.yaml and uncomment lines starting with HTTP.
// This function is based on the one from package flutter-aws-iot, but adapted slightly
String getWebSocketURL(
{required String accessKey,
Expand Down Expand Up @@ -103,13 +107,17 @@ Future<bool> attachPolicy(
final request =
sigv4Client.request('$iotApiUrl/$policyName', method: 'PUT', body: body);

var result = await put(request.url, headers: request.headers, body: body);
//HTTP remove the line below
print(request);
//HTTP var result = await put(request.url, headers: request.headers, body: body);

if (result.statusCode != 200) {
print('Error attaching IoT Policy ${result.body}');
}
//HTTP if (result.statusCode != 200) {
//HTTP print('Error attaching IoT Policy ${result.body}');
//HTTP }

return result.statusCode == 200;
//HTTP return result.statusCode == 200;
//HTTP remove the line below
return true;
}

Future<int> main() async {
Expand Down
26 changes: 18 additions & 8 deletions example/aws_iot_cognito_amplify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:aws_signature_v4/aws_signature_v4.dart';

import 'package:mqtt_client/mqtt_server_client.dart';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:http/http.dart';
//HTTP import 'package:http/http.dart';
import 'package:sigv4/sigv4.dart';

/// An example of connecting to the AWS IoT Core MQTT broker and publishing to a devices topic.
Expand All @@ -25,6 +25,10 @@ import 'package:sigv4/sigv4.dart';
/// https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html, please read this
/// before setting up and running this example.
/// Note the dependency on the http package has been removed from the client, as such lines below
/// depending on this are commented out. If you wish to run this example please re add package http
/// at version 1.2.1 to the pubspec.yaml and uncomment lines starting with HTTP.
// This function is based on the one from package flutter-aws-iot, but adapted slightly
String getWebSocketURL(
{required String accessKey,
Expand Down Expand Up @@ -76,16 +80,22 @@ Future<bool> attachPolicy(

final body = json.encode({'target': identityId});

final request =
sigv4Client.request('$iotApiUrl/$policyName', method: 'PUT', body: body);
//HTTP remove the two lines below.
print(sigv4Client);
print(body);

var result = await put(request.url, headers: request.headers, body: body);
//HTTPfinal request =
//HTTPsigv4Client.request('$iotApiUrl/$policyName', method: 'PUT', body: body);

if (result.statusCode != 200) {
print('Error attaching IoT Policy ${result.body}');
}
//HTTP var result = await put(request.url, headers: request.headers, body: body);

//HTTPf (result.statusCode != 200) {
//HTTPprint('Error attaching IoT Policy ${result.body}');
//HTTP}

return result.statusCode == 200;
//HTTPreturn result.statusCode == 200;
//HTTP remove the line below
return true;
}

Future<int> main() async {
Expand Down
19 changes: 9 additions & 10 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@ environment:
dependencies:
typed_data: '^1.3.2'
event_bus: '^2.0.0'
path: '^1.8.2'
path: '^1.9.0'
universal_html: '^2.2.4'
crypto: '^3.0.3'
meta: '^1.9.1'
meta: '^1.15.0'

dev_dependencies:
test: '^1.25.0'
lints: '^3.0.0'
build_runner: '^2.4.4'
test: '^1.25.8'
lints: '^4.0.0'
build_runner: '^2.4.11'
build_test: '^2.2.2'
build_web_compilers: '^4.0.3'
http: '^0.13.6'
build_web_compilers: '^4.0.10'
sigv4: '^5.0.0'
mocktail: '^1.0.2'
aws_signature_v4: ^0.5.1
aws_common: ^0.6.3
mocktail: '^1.0.4'
aws_signature_v4: '^0.6.0'
aws_common: '^0.7.0'

false_secrets:
- /test/pem/self_signed.key
Expand Down
1 change: 1 addition & 0 deletions test/manual/mqtt_client_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright : S.Hamblett
*/
@TestOn('linux')
library;

import 'dart:io';
import 'package:test/test.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('browser')
library;

import 'package:mqtt_client/mqtt_client.dart';
import 'package:mqtt_client/mqtt_browser_client.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('browser')
library;

import 'package:mqtt_client/mqtt_client.dart';
import 'package:mqtt_client/mqtt_browser_client.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('browser')
library;

import 'package:mqtt_client/mqtt_client.dart';
import 'package:mqtt_client/mqtt_browser_client.dart';
Expand Down
1 change: 1 addition & 0 deletions test/mqtt_client_base_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright : S.Hamblett
*/
@TestOn('vm')
library;

import 'dart:async';
import 'dart:io';
Expand Down
2 changes: 2 additions & 0 deletions test/mqtt_client_connection_autoreconnect_nobroker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

@TestOn('vm')
library;

import 'dart:io';

import 'package:mqtt_client/mqtt_client.dart';
Expand Down
1 change: 1 addition & 0 deletions test/mqtt_client_connection_autoreconnect_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('vm')
library;

import 'dart:io';

Expand Down
1 change: 1 addition & 0 deletions test/mqtt_client_connection_secure_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('vm')
library;

import 'dart:io';
import 'package:mqtt_client/mqtt_client.dart';
Expand Down
1 change: 1 addition & 0 deletions test/mqtt_client_connection_unsecure_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('vm')
library;

import 'dart:io';
import 'package:mqtt_client/mqtt_client.dart';
Expand Down
1 change: 1 addition & 0 deletions test/mqtt_client_connection_ws_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('vm')
library;

import 'dart:io';
import 'package:mqtt_client/mqtt_client.dart';
Expand Down
1 change: 1 addition & 0 deletions test/mqtt_client_keep_alive_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('vm')
library;

import 'package:mqtt_client/mqtt_client.dart';
import 'package:mqtt_client/mqtt_server_client.dart';
Expand Down
1 change: 1 addition & 0 deletions test/mqtt_client_management_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('vm')
library;

import 'dart:async';

Expand Down
1 change: 1 addition & 0 deletions test/mqtt_client_message_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

@TestOn('vm')
library;

import 'package:mqtt_client/mqtt_client.dart';
import 'package:test/test.dart';
Expand Down
2 changes: 2 additions & 0 deletions test/mqtt_client_publishing_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

@TestOn('vm')
library;

import 'dart:io';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:mqtt_client/mqtt_server_client.dart';
Expand Down
2 changes: 2 additions & 0 deletions test/mqtt_client_subscription_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

@TestOn('vm')
library;

import 'dart:io';
import 'dart:async';
import 'package:mqtt_client/mqtt_client.dart';
Expand Down

0 comments on commit 9327a4b

Please sign in to comment.