Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kpro_lib): ignore space in bootstrap endpoints string #115

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 4.1.4
- Ignore space in comma-separated hosts string.
- Add more detailed information when server returned API version range is not supported.

* 4.1.3
- Bump snappyer dependency from 1.2.8 to 1.2.9 (supports GCC 13).
- Fix scram auth client final message.
Expand Down
2 changes: 1 addition & 1 deletion src/kpro_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ parse_endpoints(Protocol, Str) ->
{Protocol, Endpoint} -> [Endpoint | Acc];
_ -> Acc
end
end, [], string:tokens(Str, ",\n")).
end, [], string:tokens(Str, ",\n ")).

%% @doc Encode primitives.
-spec encode(primitive_type(), kpro:primitive()) -> iodata().
Expand Down
17 changes: 17 additions & 0 deletions test/kpro_lib_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ with_timeout_test_() ->
}
].

parse_endpoints_test_() ->
[ {"empty", ?_assertEqual([], parse(""))}
, {"single", ?_assertEqual([{"127.0.0.1", 1234}], parse("127.0.0.1:1234"))}
, {"comma", ?_assertEqual([{"h1", 1234}, {"h2", 1235}], parse("h1:1234, h2:1235"))}
, {"space", ?_assertEqual([{"host1", 1234}, {"host2", 1235}], parse("host1:1234 host2:1235"))}
, {"plain", ?_assertEqual([{"127.0.0.1", 1234}], parse(plaintext, "plaintext://127.0.0.1:1234"))}
, {"ssl", ?_assertEqual([{"127.0.0.1", 1234}], parse(ssl, "SSL://127.0.0.1:1234"))}
, {"sasl_ssl", ?_assertEqual([{"host", 1234}], parse(sasl_ssl, "SASL_ssl://host:1234\n"))}
, {"sasl_plaintext", ?_assertEqual([{"h", 1234}], parse(sasl_plaintext, "sasl_plaintext://h:1234, "))}
].

parse(Endpoints) ->
kpro_lib:parse_endpoints(undefined, Endpoints).

parse(Proto, Endpoints) ->
kpro_lib:parse_endpoints(Proto, Endpoints).

%%%_* Emacs ====================================================================
%%% Local Variables:
%%% allout-layout: t
Expand Down
Loading