Skip to content

Commit 3b5554e

Browse files
Tsukilcimbajin
authored andcommitted
fix(server): fix auth test (#64)
* fix(server): Delete the redundant storage during the test * fix(server): fix auth test
1 parent 940a7b1 commit 3b5554e

5 files changed

Lines changed: 128 additions & 148 deletions

File tree

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/auth/HugeBelong.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class HugeBelong extends Relationship {
4040
public static final String GR = "gr";
4141
public static final String ALL = "*";
4242
private static final long serialVersionUID = -7242751631755533423L;
43+
public static final String DEFAULT_GRAPH_SPACE = "DEFAULT";
4344

4445
private String graphSpace;
4546
private Id user;
@@ -49,7 +50,7 @@ public class HugeBelong extends Relationship {
4950
private String link;
5051

5152
public HugeBelong(Id user, Id group) {
52-
this("*", user, group, null, UG);
53+
this(DEFAULT_GRAPH_SPACE, user, group, null, UG);
5354
}
5455

5556
public HugeBelong(String graphSpace, Id user, Id role) {

hugegraph-server/hugegraph-test/pom.xml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -312,26 +312,6 @@
312312
<serializer>text</serializer>
313313
</properties>
314314
</profile>
315-
<profile>
316-
<id>cassandra</id>
317-
<activation>
318-
<activeByDefault>false</activeByDefault>
319-
</activation>
320-
<properties>
321-
<backend>cassandra</backend>
322-
<serializer>cassandra</serializer>
323-
</properties>
324-
</profile>
325-
<profile>
326-
<id>scylladb</id>
327-
<activation>
328-
<activeByDefault>false</activeByDefault>
329-
</activation>
330-
<properties>
331-
<backend>scylladb</backend>
332-
<serializer>scylladb</serializer>
333-
</properties>
334-
</profile>
335315
<profile>
336316
<id>rocksdb</id>
337317
<activation>
@@ -342,26 +322,6 @@
342322
<serializer>binary</serializer>
343323
</properties>
344324
</profile>
345-
<profile>
346-
<id>mysql</id>
347-
<activation>
348-
<activeByDefault>false</activeByDefault>
349-
</activation>
350-
<properties>
351-
<backend>mysql</backend>
352-
<serializer>mysql</serializer>
353-
</properties>
354-
</profile>
355-
<profile>
356-
<id>palo</id>
357-
<activation>
358-
<activeByDefault>false</activeByDefault>
359-
</activation>
360-
<properties>
361-
<backend>palo</backend>
362-
<serializer>palo</serializer>
363-
</properties>
364-
</profile>
365325
<profile>
366326
<id>hbase</id>
367327
<activation>
@@ -372,16 +332,6 @@
372332
<serializer>hbase</serializer>
373333
</properties>
374334
</profile>
375-
<profile>
376-
<id>postgresql</id>
377-
<activation>
378-
<activeByDefault>false</activeByDefault>
379-
</activation>
380-
<properties>
381-
<backend>postgresql</backend>
382-
<serializer>postgresql</serializer>
383-
</properties>
384-
</profile>
385335
<profile>
386336
<id>hstore</id>
387337
<activation>

hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/AuthTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ public void clearAll() {
131131
for (HugeTarget target : authManager.listAllTargets(-1)) {
132132
authManager.deleteTarget(target.id());
133133
}
134+
for (HugeBelong belong : authManager.listAllBelong(-1)) {
135+
authManager.deleteBelong(belong.id());
136+
}
134137

135138
//FIXME: support project in hstore
136139
boolean isHstore = Objects.equals("hstore", System.getProperty("backend")) ||
@@ -710,12 +713,11 @@ public void testCreateBelong() {
710713
Map<String, Object> expected = new HashMap<>();
711714
expected.putAll(ImmutableMap.of("id", belong.id(),
712715
"user", user,
713-
"graphspace", "*",
716+
"graphspace", "DEFAULT",
714717
"group", group1));
715718
expected.putAll(ImmutableMap.of("belong_creator", "admin",
716719
"belong_create", belong.create(),
717720
"belong_update", belong.update()));
718-
expected.put("role", null);
719721
expected.put("link", "ug");
720722
Assert.assertEquals(expected, belong.asMap());
721723

@@ -728,12 +730,11 @@ public void testCreateBelong() {
728730
expected = new HashMap<>();
729731
expected.putAll(ImmutableMap.of("id", belong.id(),
730732
"user", user,
731-
"graphspace", "*",
733+
"graphspace", "DEFAULT",
732734
"group", group2));
733735
expected.putAll(ImmutableMap.of("belong_creator", "admin",
734736
"belong_create", belong.create(),
735737
"belong_update", belong.update()));
736-
expected.put("role", null);
737738
expected.put("link", "ug");
738739
Assert.assertEquals(expected, belong.asMap());
739740

@@ -760,13 +761,12 @@ public void testCreateBelong() {
760761
expected = new HashMap<>();
761762
expected.putAll(ImmutableMap.of("id", belong.id(),
762763
"user", user1,
763-
"graphspace", "*",
764+
"graphspace", "DEFAULT",
764765
"group", group1));
765766
expected.putAll(ImmutableMap.of("belong_description", "something2",
766767
"belong_creator", "admin",
767768
"belong_create", belong.create(),
768769
"belong_update", belong.update()));
769-
expected.put("role", null);
770770
expected.put("link", "ug");
771771
Assert.assertEquals(expected, belong.asMap());
772772

hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.hugegraph.HugeGraph;
2121
import org.apache.hugegraph.dist.RegisterUtil;
2222
import org.apache.hugegraph.masterelection.GlobalMasterInfo;
23+
import org.apache.hugegraph.meta.MetaManager;
2324
import org.apache.hugegraph.testutil.Utils;
2425
import org.apache.hugegraph.util.Log;
2526
import org.junit.AfterClass;
@@ -74,6 +75,21 @@ public static void init() {
7475
graph.clearBackend();
7576
graph.initBackend();
7677
graph.serverStarted(GlobalMasterInfo.master("server-test"));
78+
79+
// Initialize DEFAULT graphspace for V2 tests
80+
try {
81+
MetaManager metaManager =
82+
MetaManager.instance();
83+
if (metaManager.isReady()) {
84+
metaManager.initDefaultGraphSpace();
85+
}
86+
} catch (Exception e) {
87+
// MetaManager may not be initialized for non-hstore backends
88+
LOG.debug(
89+
"Failed to initialize default graphspace (expected for non-hstore backends): " +
90+
"{}",
91+
e.getMessage());
92+
}
7793
}
7894

7995
@AfterClass

0 commit comments

Comments
 (0)