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

Enhance API to handle global groups in local contexts #1159

Merged
merged 16 commits into from
Apr 26, 2017
Prev Previous commit
Next Next commit
Fix ordering issue
Signed-off-by: Mark Anderson <[email protected]>
markan authored and stevendanna committed Apr 25, 2017

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 26db94484551189caee0b012c85acd3821e76830
Original file line number Diff line number Diff line change
@@ -435,7 +435,7 @@ render_names_in_context(OrgId, ScopedNames, Context) ->
GroupedScopedNames = group_by_key(ScopedNames),
{Expanded, _Cache} = lists:foldl(fun(E, A) -> render_names_in_context_f(OrgId, E, A) end,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not use the Context in this fun. This is the only place we consume render_names_in_context_f and we drop it in _Cache. The fun itself is not using it so maybe we should remove it?

{[], Context}, GroupedScopedNames),
lists:flatten(Expanded).
lists:sort(lists:flatten(Expanded)).

%% We are in the same scope, omit qualifier
render_names_in_context_f(OrgId, {OrgId, Names}, {Expanded, Context}) ->
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@
-define(GLOBAL_NAME_AUTHZ_ID, global_name_authz_id).
-define(ORGLOCAL_NAME_AUTHZ_ID, orglocal_name_authz_id).

-define(SCOPE_PERMUTATIONS, [{?ORG1_ID, ?PLAIN_GROUP}, {?ORG2_ID, ?PLAIN_GROUP}, {?GLOBAL_PLACEHOLDER_ORG_ID, ?PLAIN_GROUP}]).
-define(SCOPE_PERMUTATIONS, lists:sort([{?ORG1_ID, ?PLAIN_GROUP}, {?ORG2_ID, ?PLAIN_GROUP}, {?GLOBAL_PLACEHOLDER_ORG_ID, ?PLAIN_GROUP}])).

%% Copypast for oc_chef_authz_scoped_name.erl
%-record(context, {org_name :: undefined,
@@ -309,7 +309,8 @@ render_names_in_context_test_() ->
{"longer list returns and and no errors",
fun() ->
Answer = Subject(?ORG1_ID, ?SCOPE_PERMUTATIONS, Context),
?assertEqual([?ORGLOCAL_GROUP,?PLAIN_GROUP, ?M:make_name(<<>>,?PLAIN_GROUP)],
Expected = lists:sort([?ORGLOCAL_GROUP,?PLAIN_GROUP, ?M:make_name(<<>>,?PLAIN_GROUP)]),
?assertEqual(Expected,
Answer)
end
}