Skip to content

Commit

Permalink
Merge pull request #58 from govorox/unit_test_private_api
Browse files Browse the repository at this point in the history
Unit test private api
  • Loading branch information
RobertByrnes authored Nov 20, 2023
2 parents 3637e73 + 6e94862 commit eee8718
Show file tree
Hide file tree
Showing 12 changed files with 2,687 additions and 441 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
lib/*
test.log
.vscode
emulation.log
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<!-- [Arduino Libraries Log](https://downloads.arduino.cc/libraries/logs/github.com/govorox/SSLClient/) -->

### Now updated on PlatformIO registry as digitaldragon/[email protected].6
### Updated on Arduino Libraries registry to digitaldragon/[email protected].6
### Now updated on PlatformIO registry as digitaldragon/[email protected].7
### Updated on Arduino Libraries registry to digitaldragon/[email protected].7

# SSLClient Arduino library using *mbedtls* functions
The SSLClient class implements support for secure connections using TLS (SSL). It Provides a transparent SSL wrapper over existing transport object of a **Client** class.
Expand Down
3 changes: 2 additions & 1 deletion Release Note.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ SSL Client Updates:
5. Fix buffer issue when writing data larger than receiving buffer, Commit: 4ce6c5f
6. Fix issue where client read timeout value not being set, Commit: 59ae9f0
7. Add clarity to return values for start_ssl_client and fix early termination of ssl client, Commit: cc40266
8. Close issue [#30](https://github.com/govorox/SSLClient/issues/30), Commit: e426936
8. Close issue [#30](https://github.com/govorox/SSLClient/issues/30), Commit: e426936
9. Separate concerns from start_ssl_client into singly responsible functions and unit test private API, commit: 0f1fa36
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SSLClient",
"version": "1.1.6",
"version": "1.1.7",
"repository":
{
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=GovoroxSSLClient
version=1.1.6
version=1.1.7
author=V Govorovski
maintainer=Robert Byrnes <[email protected]>
sentence=Provides secure network connection over a generic Client trasport object.
Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ test_framework = unity
platform = native
build_type = test
lib_deps =
digitaldragon/Emulation@^0.0.9
armmbed/mbedtls@^2.23.0
digitaldragon/Emulation@0.1.5
# armmbed/mbedtls@^2.23.0
lib_ldf_mode = deep+
build_unflags = -std=gnu++11
build_flags =
Expand Down
11 changes: 7 additions & 4 deletions src/SSLClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ SSLClient::~SSLClient() {
void SSLClient::stop() {
if (sslclient->client != nullptr) {
if (sslclient->client >= 0) {
log_i("Stopping ssl client");
log_d("Stopping ssl client");
stop_ssl_socket(sslclient, _CA_cert, _cert, _private_key);
} else {
log_i("stop() not called because client is < 0");
log_d("stop() not called because client is < 0");
}
} else {
log_i("stop() not called because client is nullptr");
log_d("stop() not called because client is nullptr");
}
_connected = false;
_peek = -1;
Expand Down Expand Up @@ -277,7 +277,7 @@ int SSLClient::connect(IPAddress ip, uint16_t port, const char *pskIdent, const
int SSLClient::connect(const char *host, uint16_t port, const char *pskIdent, const char *psKey) {
log_v("start_ssl_client with PSK");

if(_timeout > 0){
if (_timeout > 0) {
sslclient->handshake_timeout = _timeout;
}

Expand Down Expand Up @@ -366,12 +366,15 @@ size_t SSLClient::write(uint8_t data) {
*/
size_t SSLClient::write(const uint8_t *buf, size_t size) {
if (!_connected) {
log_w("SSLClient is not connected.");
return 0;
}

log_d("Sending data to SSL connection...");
int res = send_ssl_data(sslclient, buf, size);

if (res < 0) {
log_e("Error sending data to SSL connection. Stopping SSLClient...");
stop();
res = 0;
}
Expand Down
Loading

0 comments on commit eee8718

Please sign in to comment.