Skip to content

Commit

Permalink
Merge pull request #5 from JuliaWeb/get-error
Browse files Browse the repository at this point in the history
Fix exception in get_error, and release a new version
  • Loading branch information
JamesWrigley committed Feb 27, 2024
2 parents 5777bcc + 5e2062a commit 3b45a47
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LibSSH"
uuid = "00483490-30f8-4353-8aba-35b82f51f4d0"
authors = ["James Wrigley <[email protected]> and contributors"]
version = "0.2.0"
version = "0.2.1"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand Down
9 changes: 7 additions & 2 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ CurrentModule = LibSSH
This documents notable changes in LibSSH.jl. The format is based on [Keep a
Changelog](https://keepachangelog.com).

## Unreleased
## [v0.2.1] - 2024-02-27

### Added

- Initial client support for GSSAPI authentication ([#3]).
- Initial client support for GSSAPI authentication ([#3]). This is not fully
tested, so use it with caution.

### Changed

- Renamed `channel_send_eof()` to [`closewrite(::SshChannel)`](@ref) ([#4]).

### Fixed

- An exception in [`get_error(::SshChannel)`](@ref) ([#5]).

## [v0.2.0] - 2024-02-01

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/session.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Get the last error set by libssh.
Wrapper around [`lib.ssh_get_error()`](@ref).
"""
function get_error(session::Session)
if !isassigned(session.ptr)
if !isassigned(session)
throw(ArgumentError("Session has been free'd, cannot get its error"))
end

Expand Down
6 changes: 6 additions & 0 deletions test/LibSSHTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ end
# Unsetting a ssh_bind option shouldn't be allowed
@test_throws ArgumentError server.port = nothing

@test ssh.get_error(server) == ""

# Basic listener test
t = errormonitor(@async ssh.listen(_ -> nothing, server))
ssh.wait_for_listener(server)
Expand Down Expand Up @@ -191,8 +193,12 @@ end
end

@testset "Session" begin
# Connecting to a nonexistent ssh server should fail
@test_throws ssh.LibSSHException ssh.Session("localhost", 42)

session = ssh.Session("localhost"; auto_connect=false, log_verbosity=lib.SSH_LOG_NOLOG)
@test !ssh.isconnected(session)
@test ssh.get_error(session) == ""

# Authenticating on an unconnected session should error
@test_throws ArgumentError ssh.userauth_none(session)
Expand Down

0 comments on commit 3b45a47

Please sign in to comment.