Skip to content

Commit

Permalink
Rename generatePrivateKey to generateKeyPair
Browse files Browse the repository at this point in the history
  • Loading branch information
tadaskay committed Mar 29, 2023
1 parent 70ef73d commit 0b0b26d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class _MyAppState extends State<MyApp> {
}

void generateKey() {
_wireguardDartPlugin.generatePrivateKey().then((value) => {print(value)});
_wireguardDartPlugin.generateKeyPair().then((value) => {print(value)});
}

@override
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/SwiftWireguardDartPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SwiftWireguardDartPlugin: NSObject, FlutterPlugin {

public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "generatePrivateKey":
case "generateKeyPair":
let privateKey = PrivateKey()
let privateKeyResponse: [String: Any] = [
"privateKey": privateKey.base64Key,
Expand Down
4 changes: 2 additions & 2 deletions lib/wireguard_dart.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'wireguard_dart_platform_interface.dart';

class WireguardDart {
Future<Map<String, String>> generatePrivateKey() {
return WireguardDartPlatform.instance.generatePrivateKey();
Future<Map<String, String>> generateKeyPair() {
return WireguardDartPlatform.instance.generateKeyPair();
}

Future<void> setupTunnel({required String bundleId}) {
Expand Down
4 changes: 2 additions & 2 deletions lib/wireguard_dart_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class MethodChannelWireguardDart extends WireguardDartPlatform {
final methodChannel = const MethodChannel('wireguard_dart');

@override
Future<Map<String, String>> generatePrivateKey() async {
return Map<String, String>.from(await methodChannel.invokeMethod('generatePrivateKey'));
Future<Map<String, String>> generateKeyPair() async {
return Map<String, String>.from(await methodChannel.invokeMethod('generateKeyPair'));
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/wireguard_dart_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ abstract class WireguardDartPlatform extends PlatformInterface {
_instance = instance;
}

Future<Map<String, String>> generatePrivateKey() {
throw UnimplementedError('generatePrivateKey() has not been implemented');
Future<Map<String, String>> generateKeyPair() {
throw UnimplementedError('generateKeyPair() has not been implemented');
}

Future<void> setupTunnel({required String bundleId}) {
Expand Down
2 changes: 1 addition & 1 deletion macos/Classes/WireguardDartPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WireguardDartPlugin: NSObject, FlutterPlugin {

public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "generatePrivateKey":
case "generateKeyPair":
let privateKey = PrivateKey()
let privateKeyResponse: [String: Any] = [
"privateKey": privateKey.base64Key,
Expand Down
6 changes: 3 additions & 3 deletions test/wireguard_dart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MockWireguardDartPlatform with MockPlatformInterfaceMixin implements Wireg
Future<void> disconnect() => Future.value();

@override
Future<Map<String, String>> generatePrivateKey() {
Future<Map<String, String>> generateKeyPair() {
return Future(() => Map.of({
'privateKey': 'dududu',
'publicKey': 'dududududu',
Expand All @@ -30,12 +30,12 @@ void main() {
expect(initialPlatform, isInstanceOf<MethodChannelWireguardDart>());
});

test('generatePrivateKey', () async {
test('generateKeyPair', () async {
WireguardDart wireguardDartPlugin = WireguardDart();
MockWireguardDartPlatform fakePlatform = MockWireguardDartPlatform();
WireguardDartPlatform.instance = fakePlatform;

final result = await wireguardDartPlugin.generatePrivateKey();
final result = await wireguardDartPlugin.generateKeyPair();
expect(result, isMap);
expect(result, containsPair('privateKey', 'dududu'));
expect(result, containsPair('publicKey', 'dududududu'));
Expand Down

0 comments on commit 0b0b26d

Please sign in to comment.