Skip to content

Commit

Permalink
fix broken tests; update sync script to upload changelog to s3; bump …
Browse files Browse the repository at this point in the history
…version; update changelog
  • Loading branch information
gammelby committed Sep 14, 2022
1 parent 414fecf commit f6e466c
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 83 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# Changelog

## [3.0.2]
## [3.0.3] - 2022-09-14

### Changed

* Update underlying Nabto Edge Client SDK to 5.11.0.

## [3.0.2] - 2022-09-05

### Bug fixes

* Fixed crash in mDNS scanner that could occur if scan was stopped while a result callback was still active.

## [3.0.1]
## [3.0.1] - 2022-08-31

### Bug fixes

* Fixed wrong visibility of members in NabtoEdgeClientLogMessage

## [3.0.0]
## [3.0.0] - 2022-06-12

### Breaking

Expand Down
131 changes: 65 additions & 66 deletions NabtoEdgeClient/NabtoEdgeClientTests/NabtoEdgeClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,72 +20,6 @@ import Foundation
// "Host Application" setting under the "General" tab for the test target). Note that this then fails or simulator - so
// to change back and forth between device and simulator, this option must be toggled between "None" and the host application ("HostsForTests").


class NabtoEdgeClientTestBase: XCTestCase {
let testDevices = TestDevices()
var connection: Connection! = nil
var client: Client!
var clientRefCount: Int?
var connectionRefCount: Int?
let streamPort: UInt32 = 42

func uniqueUser() -> String {
String(UUID().uuidString.lowercased().prefix(16))
}

override func setUpWithError() throws {
print(Client.versionString())
setbuf(__stdoutp, nil)
continueAfterFailure = false

XCTAssertNil(self.client)
self.client = Client()
try self.enableLogging(self.client)
self.clientRefCount = CFGetRetainCount(self.client)

XCTAssertNil(self.connection)
self.connection = try client.createConnection()
self.connectionRefCount = CFGetRetainCount(self.connection)
}

override func tearDownWithError() throws {
do {
try self.connection?.close()
} catch (NabtoEdgeClientError.STOPPED) {
// client stopped
} catch (NabtoEdgeClientError.NOT_CONNECTED) {
// connection probably not opened yet
}
if (self.connection != nil) {
XCTAssertEqual(self.connectionRefCount, CFGetRetainCount(self.connection))
self.connection = nil
}
if (self.client != nil) {
self.client.stop()
XCTAssertEqual(self.clientRefCount, CFGetRetainCount(self.client))
self.client = nil
}
XCTAssertNil(self.client)
XCTAssertNil(self.connection)
}

func enableLogging(_ client: Client) throws {
try client.setLogLevel(level: "info")
client.enableNsLogLogging()
}

func prepareConnection(_ device: TestDevice) throws {
let key = try client.createPrivateKey()
try self.connection.setPrivateKey(key: key)
try self.connection.updateOptions(json: device.asJson())
}

func connect(_ device: TestDevice) throws{
try self.prepareConnection(device)
try self.connection.connect()
}
}

class NabtoEdgeClientTests: NabtoEdgeClientTestBase {

func testVersionString() throws {
Expand Down Expand Up @@ -1111,3 +1045,68 @@ class NabtoEdgeClientTests: NabtoEdgeClientTestBase {
exp.fulfill()
}
}

class NabtoEdgeClientTestBase: XCTestCase {
let testDevices = TestDevices()
var connection: Connection! = nil
var client: Client!
var clientRefCount: Int?
var connectionRefCount: Int?
let streamPort: UInt32 = 42

func uniqueUser() -> String {
String(UUID().uuidString.lowercased().prefix(16))
}

override func setUpWithError() throws {
print(Client.versionString())
setbuf(__stdoutp, nil)
continueAfterFailure = false

XCTAssertNil(self.client)
self.client = Client()
try self.enableLogging(self.client)
self.clientRefCount = CFGetRetainCount(self.client)

XCTAssertNil(self.connection)
self.connection = try client.createConnection()
self.connectionRefCount = CFGetRetainCount(self.connection)
}

override func tearDownWithError() throws {
do {
try self.connection?.close()
} catch (NabtoEdgeClientError.STOPPED) {
// client stopped
} catch (NabtoEdgeClientError.NOT_CONNECTED) {
// connection probably not opened yet
}
if (self.connection != nil) {
XCTAssertEqual(self.connectionRefCount, CFGetRetainCount(self.connection))
self.connection = nil
}
if (self.client != nil) {
self.client.stop()
XCTAssertEqual(self.clientRefCount, CFGetRetainCount(self.client))
self.client = nil
}
XCTAssertNil(self.client)
XCTAssertNil(self.connection)
}

func enableLogging(_ client: Client) throws {
try client.setLogLevel(level: "info")
client.enableNsLogLogging()
}

func prepareConnection(_ device: TestDevice) throws {
let key = try client.createPrivateKey()
try self.connection.setPrivateKey(key: key)
try self.connection.updateOptions(json: device.asJson())
}

func connect(_ device: TestDevice) throws{
try self.prepareConnection(device)
try self.connection.connect()
}
}
15 changes: 11 additions & 4 deletions NabtoEdgeClient/NabtoEdgeClientTests/TestDeviceDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ struct TestDevice {
}

func asJson() -> String {
let pk = """
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIAl3ZURem5NMCTZA0OeTPcT7y6T2FHjHhmQz54UiH7mQoAoGCCqGSM49
AwEHoUQDQgAEbiabrII+WZ8ABD4VQpmLe3cSIWdQfrRbxXotx5yxwInfgLuDU+rq
OIFReqTf5h+Nwp/jj00fnsII88n1YCveoQ==
-----END EC PRIVATE KEY-----
"""
let sctElement = sct != nil ? "\"ServerConnectToken\": \"\(sct!)\",\n" : ""
return """
{\n
\"Local\": \(self.local),\n
\"PrivateKey\": "foo",\n
\"ProductId\": \"\(self.productId)\",\n
\"DeviceId\": \"\(self.deviceId)\",\n
\"ServerUrl\": \"\(self.url)\",\n
Expand All @@ -44,15 +52,14 @@ struct TestDevices {
productId: "pr-fatqcwj9",
deviceId: "de-avmqjaje",
url: "https://pr-fatqcwj9.clients.nabto.net",
key: "sk-5f3ab4bea7cc2585091539fb950084ce",
fp: "fcb78f8d53c67dbc4f72c36ca6cd2d5fc5592d584222059f0d76bdb514a9340c"
)
key: "sk-72c860c244a6014248e64d5273e3e0ec",
fp: "fcb78f8d53c67dbc4f72c36ca6cd2d5fc5592d584222059f0d76bdb514a9340c")

let streamDevice = TestDevice(
productId: "pr-fatqcwj9",
deviceId: "de-bdsotcgm",
url: "https://pr-fatqcwj9.clients.nabto.net",
key: "sk-5f3ab4bea7cc2585091539fb950084ce"
key: "sk-72c860c244a6014248e64d5273e3e0ec"
)

let tunnelDevice = TestDevice(
Expand Down
4 changes: 2 additions & 2 deletions NabtoEdgeClient/Podfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# changes seems to take forever to synchronize to pods 1.8+ CDN, use old
# github approach for immediate retrieval (but slower once synched, so only
# relevant during development)
#source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!

platform :ios, '10.2'

target 'NabtoEdgeClient' do
pod 'NabtoEdgeClientApiFW', '5.9.0'
pod 'NabtoEdgeClientApiFW', '5.11.0'
end

target 'HostForTests' do
Expand Down
8 changes: 4 additions & 4 deletions NabtoEdgeClient/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- NabtoEdgeClientApiFW (5.9.0)
- NabtoEdgeClientApiFW (5.11.0)

DEPENDENCIES:
- NabtoEdgeClientApiFW (= 5.9.0)
- NabtoEdgeClientApiFW (= 5.11.0)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
- NabtoEdgeClientApiFW

SPEC CHECKSUMS:
NabtoEdgeClientApiFW: d5d444aba9cd3b1fe597174bdd30970c4bcab887
NabtoEdgeClientApiFW: dfee3f1749659409e66f2227931c8d215dfee779

PODFILE CHECKSUM: abd4458c3107a122764a6ea9901221a450412755
PODFILE CHECKSUM: c34b90159de55ec7b02a6471d73affb7c1ec97d4

COCOAPODS: 1.11.3
2 changes: 1 addition & 1 deletion NabtoEdgeClientSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'NabtoEdgeClientSwift'
s.version = "3.0.2"
s.version = "3.0.3"
s.summary = "Nabto 5/Edge Client for Swift"
s.description = <<-DESC
This pod installs the high level Nabto Edge Client for Swift: It wraps the most common functionality of the low-level ANSI C Nabto Edge Client SDK (provided in the NabtoEdgeClientApi pod).
Expand Down
17 changes: 14 additions & 3 deletions sync.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/bash

set -e

FILE=`pwd`/dist/NabtoEdgeClient.xcframework.zip
CHANGELOG=`pwd`/CHANGELOG.md

if [ ! -f $FILE ]; then
echo "Could find framework zip file $FILE"
echo "Could not find framework zip file $FILE"
exit 1
fi

if [ ! -f $CHANGELOG ]; then
echo "Could not find changelog $CHANGELOG"
exit 1
fi

Expand All @@ -16,12 +20,19 @@ if [ -z $VERSION ]; then
exit 1
fi

grep -q $VERSION CHANGELOG.md
if [ $? != "0" ]; then
echo "Missing documentation of version $VERSION in changelog"
exit 1
fi

DIR=`mktemp -d`
cd $DIR

SUBDIR="ios/nabto-client-swift/$VERSION"
mkdir -p $SUBDIR
cp $FILE $SUBDIR
cp $CHANGELOG $SUBDIR

S3URL="s3://downloads.nabto.com/assets/edge"
tree ios
Expand Down

0 comments on commit f6e466c

Please sign in to comment.