-
Notifications
You must be signed in to change notification settings - Fork 526
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
add user-api test #1456
add user-api test #1456
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1456 +/- ##
============================================
+ Coverage 61.80% 64.05% +2.25%
- Complexity 5840 5882 +42
============================================
Files 381 381
Lines 32148 32190 +42
Branches 4504 4506 +2
============================================
+ Hits 19869 20620 +751
+ Misses 10231 9463 -768
- Partials 2048 2107 +59
Continue to review full report at Codecov.
|
ImmutableMap.of()); | ||
assertResponseStatus(200, r); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the empty line
String result = assertResponseStatus(400, r); | ||
String message = assertJsonContains(result, "message"); | ||
Assert.assertThat(message, CoreMatchers.containsString( | ||
"Invalid user id:")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align
this.client().post(path, user); | ||
} | ||
|
||
protected List<Map<String, Object>> getList() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listUsers
Response r3 = client().post(path, "{}"); | ||
assertResponseStatus(400, r3); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
private static final String path = "graphs/hugegraph/auth/users"; | ||
|
||
@After | ||
public void clearUser() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
teardown
|
||
protected List<Map<String, Object>> getList() { | ||
Response r = this.client().get(path, | ||
ImmutableMap.of("limit", -1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define params var
String result = assertResponseStatus(200, r); | ||
Map<String, List<Map<String, Object>>> resultMap = JsonUtil.fromJson( | ||
result, | ||
new TypeReference<Map<String, List<Map<String, Object>>>>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define local var
result, | ||
new TypeReference<Map<String, List<Map<String, Object>>>>() { | ||
}); | ||
return resultMap.get("users"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JsonUtil.fromJson().get("users");
9dfd80b
to
96edf75
Compare
96edf75
to
00b22f6
Compare
@@ -5,9 +5,30 @@ set -ev | |||
TRAVIS_DIR=`dirname $0` | |||
VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout` | |||
SERVER_DIR=hugegraph-$VERSION | |||
CONF=$TRAVIS_DIR/conf/hugegraph.properties | |||
REST_CONF=$TRAVIS_DIR/conf/rest-server.properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REST_SERVER_CONF
|
||
mvn package -DskipTests | ||
|
||
cp $CONF "${CONF}_bak" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need to copy bak file
@@ -5,9 +5,30 @@ set -ev | |||
TRAVIS_DIR=`dirname $0` | |||
VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout` | |||
SERVER_DIR=hugegraph-$VERSION | |||
CONF=$TRAVIS_DIR/conf/hugegraph.properties | |||
REST_CONF=$TRAVIS_DIR/conf/rest-server.properties | |||
GREMLIN_CONF=$TRAVIS_DIR/conf/gremlin-server.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GREMLIN_SERVER_CONF
|
||
mv "${CONF}_bak" $CONF | ||
mv "${REST_CONF}_bak" $REST_CONF | ||
mv "${GREMLIN_CONF}_bak" $GREMLIN_CONF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add empty line
@@ -36,9 +36,12 @@ | |||
public class UserApiTest extends BaseApiTest { | |||
|
|||
private static final String path = "graphs/hugegraph/auth/users"; | |||
private static final Map<String, Object> NO_LIMIT = ImmutableMap.of("limit", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just define NO_LIMIT = -1;
}); | ||
Map<String, List<Map<String, Object>>> resultMap = | ||
JsonUtil.fromJson(result, new TypeReference<Map<String, | ||
List<Map<String, Object>>>>() {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return JsonUtil.fromJson(result, type).get("users");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it need to cast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update alignment
1b961e8
to
454d51a
Compare
f16fa55
to
d95d5ad
Compare
}); | ||
Map<String, List<Map<String, Object>>> resultMap = | ||
JsonUtil.fromJson(result, new TypeReference<Map<String, | ||
List<Map<String, Object>>>>() {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update alignment
|
||
mvn package -DskipTests | ||
|
||
sed -i 's/#auth.authenticator=/auth.authenticator=com.baidu.hugegraph.auth.StandardAuthenticator/' $REST_SERVER_CONF | ||
sed -i 's/gremlin.graph=.*/gremlin.graph=com.baidu.hugegraph.auth.HugeFactoryAuthProxy/' $CONF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seem no this option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seem no the option named "gremlin.graph"
"\", \"user_email\":\"user1@baidu.com\", " + | ||
"\"user_phone\"123456789\", \"user_avatar\":\"image1" + | ||
"\", \"user_email\":\"user1@baidu.com\"," + | ||
"\"user_phone\":123456789,\"user_avatar\":\"image1" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep string
@@ -93,7 +93,13 @@ public void testClearAndInit() { | |||
assertResponseStatus(200, client().post(path, body)); | |||
|
|||
body = "{" | |||
+ "\"gremlin\":\"hugegraph.initBackend()\"," | |||
+ "\"gremlin\":\"import com.baidu.hugegraph.auth.HugeUser;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't separate clearBackend and initBackend into 2 parts if enabled auth
92fd0eb
to
50e926b
Compare
+ "import com.baidu.hugegraph.util.StringEncoding;" | ||
+ "hugegraph.clearBackend();" | ||
+ "hugegraph.initBackend();" | ||
+ "HugeUser admin = new HugeUser('admin');" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auth = hugegraph.authManager();
admin = auth.findUser('admin');
hugegraph.clearBackend();
hugegraph.initBackend();
auth.createUser(admin);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -52,6 +53,8 @@ | |||
|
|||
private static String BASE_URL = "http://127.0.0.1:8080"; | |||
private static String GRAPH = "hugegraph"; | |||
protected static final String USERNAME = "admin"; | |||
protected static final String PASSWORD = "pa"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set private
NO_LIMIT)); | ||
String result = assertResponseStatus(200, r); | ||
Map<String, List<Map<String, Object>>> resultMap = | ||
JsonUtil.fromJson(result, new TypeReference<Map<String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve align
+ "hugegraph.clearBackend();" | ||
+ "hugegraph.initBackend();" | ||
+ "HugeUser admin = new HugeUser('admin');" | ||
+ "admin.password(StringEncoding.hashPassword('pa'));" | ||
+ "admin.creator('system');" | ||
+ "hugegraph.hugegraph().authManager().createUser(admin);\"," |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auth.createUser(admin);
|
||
mvn package -DskipTests | ||
|
||
sed -i 's/#auth.authenticator=/auth.authenticator=com.baidu.hugegraph.auth.StandardAuthenticator/' $REST_SERVER_CONF | ||
sed -i 's/gremlin.graph=.*/gremlin.graph=com.baidu.hugegraph.auth.HugeFactoryAuthProxy/' $CONF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seem no the option named "gremlin.graph"
* add user test * open auth properties * fix auth startup of memory backend bug
No description provided.