couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject couchdb-cassim git commit: Add prefix for security metadata documents
Date Fri, 20 Mar 2015 18:15:28 GMT
Repository: couchdb-cassim
Updated Branches:
  refs/heads/master 0450d81ba -> 4c3179365


Add prefix for security metadata documents

Because such documents starts with database name, metadata documents
for system databases violates CouchDB restriction for document id which
cannot starts with underscore unless they are not _design/ ones.

COUCHDB-2422


Project: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/commit/4c317936
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/tree/4c317936
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/diff/4c317936

Branch: refs/heads/master
Commit: 4c3179365e8d2bb65cd45049706d652374a548ba
Parents: 0450d81
Author: Alexander Shorin <kxepal@apache.org>
Authored: Wed Mar 18 20:08:07 2015 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Wed Mar 18 20:08:07 2015 +0300

----------------------------------------------------------------------
 src/cassim_metadata_cache.erl       |  2 +-
 test/cassim_metadata_cache_test.erl | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-cassim/blob/4c317936/src/cassim_metadata_cache.erl
----------------------------------------------------------------------
diff --git a/src/cassim_metadata_cache.erl b/src/cassim_metadata_cache.erl
index 85113e2..1e43dce 100644
--- a/src/cassim_metadata_cache.erl
+++ b/src/cassim_metadata_cache.erl
@@ -70,7 +70,7 @@ metadata_db_exists() ->
 
 security_meta_id(DbName) ->
     Suffix = list_to_binary(mem3:shard_suffix(DbName)),
-    <<DbName/binary, "/_security", Suffix/binary>>.
+    <<"db/", DbName/binary, "/_security", Suffix/binary>>.
 
 
 start_link() ->

http://git-wip-us.apache.org/repos/asf/couchdb-cassim/blob/4c317936/test/cassim_metadata_cache_test.erl
----------------------------------------------------------------------
diff --git a/test/cassim_metadata_cache_test.erl b/test/cassim_metadata_cache_test.erl
new file mode 100644
index 0000000..20cb65f
--- /dev/null
+++ b/test/cassim_metadata_cache_test.erl
@@ -0,0 +1,24 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(cassim_metadata_cache_test).
+
+-include_lib("eunit/include/eunit.hrl").
+
+security_meta_id_test() ->
+    meck:new(mem3),
+    meck:expect(mem3, shard_suffix, fun(_) -> ".shard_suffix" end),
+    ?assertEqual(
+        <<"db/_metadata/_security.shard_suffix">>,
+        cassim_metadata_cache:security_meta_id(<<"_metadata">>)
+    ),
+    meck:unload(mem3).


Mime
View raw message