diff options
author | Bryan Paxton <39971740+starbelly@users.noreply.github.com> | 2019-03-07 10:54:01 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2019-03-07 09:54:01 -0700 |
commit | 209c02ec57c2cc3207ee0174c3af3675b8dc8f79 (patch) | |
tree | e07b25a27a2c4cc438db75d8d066179b4e57f3f7 /test | |
parent | 9e2e54afd74104ecb05c55e033803f41932eb940 (diff) |
Fix fetching of private packages from orgs on hex repos (#2020)
- vendor in hex_core at v0.5.0
- Change where repo_name should be the org and not the parent
- Changed rebar_utils:url_append_path/2 to not explicitly add a '?',
this is returned in the Query chunk by http_uri:parse/1 (e.g., "?foo=bar")
- update organization_merging test to expect the sub-repo as the repo_name
- Add tests for rebar_utils:url_append_path/2
- Stop referencing/setting "organization" in config and use new
organization settings (api_repository and repo_organization)
- Do not set (assume) the read key is valid for any/every repo
- Set repo_organization and api_repository to org
- Update tests to check for new config opts
Diffstat (limited to 'test')
-rw-r--r-- | test/mock_pkg_resource.erl | 2 | ||||
-rw-r--r-- | test/rebar_pkg_SUITE.erl | 10 | ||||
-rw-r--r-- | test/rebar_pkg_alias_SUITE.erl | 6 | ||||
-rw-r--r-- | test/rebar_pkg_repos_SUITE.erl | 9 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 2 | ||||
-rw-r--r-- | test/rebar_utils_SUITE.erl | 10 |
6 files changed, 27 insertions, 12 deletions
diff --git a/test/mock_pkg_resource.erl b/test/mock_pkg_resource.erl index a169efd..a176e88 100644 --- a/test/mock_pkg_resource.erl +++ b/test/mock_pkg_resource.erl @@ -100,7 +100,7 @@ mock_download(Opts) -> <<"version">> => Vsn}, Files = all_files(rebar_app_info:dir(AppInfo1)), - {ok, {Tarball, _Checksum}} = hex_tarball:create(Metadata, archive_names(Dir, Files)), + {ok, {Tarball, _Checksum}} = r3_hex_tarball:create(Metadata, archive_names(Dir, Files)), Archive = filename:join([Dir, TarApp]), file:write_file(Archive, Tarball), diff --git a/test/rebar_pkg_SUITE.erl b/test/rebar_pkg_SUITE.erl index ad06abd..383f9ef 100644 --- a/test/rebar_pkg_SUITE.erl +++ b/test/rebar_pkg_SUITE.erl @@ -97,7 +97,7 @@ init_per_testcase(bad_disconnect=Name, Config0) -> {pkg, Pkg} | Config0], Config = mock_config(Name, Config1), - meck:expect(hex_repo, get_tarball, fun(_, _, _) -> + meck:expect(r3_hex_repo, get_tarball, fun(_, _, _) -> {error, econnrefused} end), Config; @@ -281,8 +281,8 @@ mock_config(Name, Config) -> end, AllDeps), - meck:new(hex_repo, [passthrough]), - meck:expect(hex_repo, get_package, + meck:new(r3_hex_repo, [passthrough]), + meck:expect(r3_hex_repo, get_package, fun(_Config, PkgName) -> Matches = ets:match_object(Tid, {{PkgName,'_'}, '_'}), Releases = @@ -303,7 +303,7 @@ mock_config(Name, Config) -> end), meck:expect(rebar_state, resources, fun(_State) -> - DefaultConfig = hex_core:default_config(), + DefaultConfig = r3_hex_core:default_config(), [rebar_resource_v2:new(pkg, rebar_pkg_resource, #{repos => [DefaultConfig#{name => <<"hexpm">>}], base_config => #{}})] @@ -325,7 +325,7 @@ mock_config(Name, Config) -> PkgFile = <<Pkg/binary, "-", Vsn/binary, ".tar">>, {ok, PkgContents} = file:read_file(filename:join(?config(data_dir, Config), PkgFile)), - meck:expect(hex_repo, get_tarball, fun(_, _, _) when GoodCache -> + meck:expect(r3_hex_repo, get_tarball, fun(_, _, _) when GoodCache -> {ok, {304, #{<<"etag">> => ?good_etag}, <<>>}}; (_, _, _) -> {ok, {200, #{<<"etag">> => ?good_etag}, PkgContents}} diff --git a/test/rebar_pkg_alias_SUITE.erl b/test/rebar_pkg_alias_SUITE.erl index 1ef5a34..bfa5058 100644 --- a/test/rebar_pkg_alias_SUITE.erl +++ b/test/rebar_pkg_alias_SUITE.erl @@ -241,8 +241,8 @@ mock_config(Name, Config) -> end, AllDeps), - meck:new(hex_repo, [passthrough]), - meck:expect(hex_repo, get_package, + meck:new(r3_hex_repo, [passthrough]), + meck:expect(r3_hex_repo, get_package, fun(_Config, PkgName) -> Matches = ets:match_object(Tid, {{PkgName,'_'}, '_'}), Releases = @@ -254,7 +254,7 @@ mock_config(Name, Config) -> {ok, {200, #{}, Releases}} end), - meck:expect(hex_repo, get_tarball, fun(_, _, _) -> + meck:expect(r3_hex_repo, get_tarball, fun(_, _, _) -> {ok, {304, #{<<"etag">> => EtagGood}, <<>>}} end), diff --git a/test/rebar_pkg_repos_SUITE.erl b/test/rebar_pkg_repos_SUITE.erl index 874da71..8446bbf 100644 --- a/test/rebar_pkg_repos_SUITE.erl +++ b/test/rebar_pkg_repos_SUITE.erl @@ -291,14 +291,23 @@ organization_merging(_Config) -> ?assertMatch({ok, #resource{state=#{repos := [#{name := <<"hexpm:repo-1">>, parent := <<"hexpm">>, + repo_name := <<"repo-1">>, + api_repository := <<"repo-1">>, + repo_organization := <<"repo-1">>, read_key := <<"read key">>, write_key := <<"write key hexpm">>}, #{name := <<"hexpm:repo-2">>, parent := <<"hexpm">>, + repo_name := <<"repo-2">>, + api_repository := <<"repo-2">>, + repo_organization := <<"repo-2">>, read_key := <<"read key 2">>, repos_key := <<"repos key 2">>, write_key := <<"write key 2">>}, #{name := <<"hexpm">>, + repo_name := <<"hexpm">>, + api_repository := undefined, + repo_organization := undefined, write_key := <<"write key hexpm">>}]}}}, rebar_pkg_resource:init(pkg, State)), diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 944efa0..b4f0043 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -511,7 +511,7 @@ package_app(AppDir, DestDir, PkgName, PkgVsn) -> Files = lists:zip([filename:join("src", F) || F <- Fs], [filename:join(AppSrc,F) || F <- Fs]), Metadata = #{<<"app">> => list_to_binary(PkgName), <<"version">> => list_to_binary(PkgVsn)}, - {ok, {Tarball, <<Checksum:256/big-unsigned-integer>>}} = hex_tarball:create(Metadata, Files), + {ok, {Tarball, <<Checksum:256/big-unsigned-integer>>}} = r3_hex_tarball:create(Metadata, Files), Name = PkgName++"-"++PkgVsn++".tar", Archive = filename:join(DestDir, Name), diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl index 233fcff..4901f40 100644 --- a/test/rebar_utils_SUITE.erl +++ b/test/rebar_utils_SUITE.erl @@ -33,7 +33,8 @@ sh_does_not_miss_messages/1, tup_merge/1, proxy_auth/1, - is_list_of_strings/1]). + is_list_of_strings/1, + url_append_path/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -49,7 +50,7 @@ all() -> [{group, args_to_tasks}, sh_does_not_miss_messages, tup_merge, - proxy_auth, is_list_of_strings]. + proxy_auth, is_list_of_strings, url_append_path]. groups() -> [{args_to_tasks, [], [empty_arglist, @@ -319,3 +320,8 @@ is_list_of_strings(_Config) -> ?assert(rebar_utils:is_list_of_strings([])), ?assert(rebar_utils:is_list_of_strings("")), ?assert(rebar_utils:is_list_of_strings("foo") == false). + +url_append_path(_Config) -> + ?assertEqual({ok, "https://repo.hex.pm:443/repos/org"}, rebar_utils:url_append_path("https://repo.hex.pm", "/repos/org")), + ?assertEqual({ok, "https://repo.hex.pm:443/repos/org?foo=bar"}, rebar_utils:url_append_path("https://repo.hex.pm", + "/repos/org?foo=bar")). |