Test enroll admin
This commit is contained in:
parent
7a4e7bf549
commit
adbfddf834
Binary file not shown.
|
@ -34,11 +34,12 @@ dependencies {
|
|||
implementation 'com.android.support:design:26.1.0'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
implementation 'org.glassfish:javax.json:1.0.4'
|
||||
//implementation 'org.glassfish:javax.json:1.0.4'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation ('org.hyperledger.fabric-sdk-java:fabric-sdk-java:1.2.1'){
|
||||
exclude group:'org.glassfish', module:'javax.json'
|
||||
implementation ('org.hyperledger.fabric-sdk-java:fabric-sdk-java:1.0.0'){
|
||||
//exclude group:'org.glassfish', module:'javax.json'
|
||||
exclude group:'log4j', module:'log4j'
|
||||
exclude group:'org.jacoco', module:"jacoco-maven-plugin"
|
||||
}
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
||||
|
@ -53,4 +54,5 @@ dependencies {
|
|||
implementation 'com.google.zxing:core:3.2.1'
|
||||
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
|
||||
implementation 'com.google.android.gms:play-services-vision:11.8.0'
|
||||
implementation group: 'com.madgag.spongycastle', name: 'core', version: '1.54.0.0'
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.support.test.InstrumentationRegistry;
|
|||
import com.example.monnthic.monnethicmobile.R;
|
||||
|
||||
|
||||
import org.hyperledger.fabric.sdk.NetworkConfig;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -20,7 +19,6 @@ import javax.json.Json;
|
|||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
|
||||
import io.grpc.internal.JsonParser;
|
||||
|
||||
|
||||
public class LearningTest {
|
||||
|
|
|
@ -19,6 +19,27 @@ import monnethic.mobile.test.blockchain.Utility.UtilTest;
|
|||
|
||||
|
||||
public class TestQuery {
|
||||
|
||||
@Test
|
||||
public void TestAEnrollAdmin() throws Exception {
|
||||
try{
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
String caUrl = Config.CA_ORG1_URL;
|
||||
CAClientWrapper caClientWrapper = new CAClientWrapper(caUrl,null,null,null);
|
||||
UserContext adminContext = new UserContext();
|
||||
adminContext.setName(Config.ADMIN);
|
||||
adminContext.setAffiliation(Config.ORG1);
|
||||
adminContext.setMspId(Config.ORG1_MSP);
|
||||
caClientWrapper.setAdminContext(adminContext);
|
||||
adminContext = caClientWrapper.enrollAdmin(appContext,Config.ADMIN,Config.ADMIN_PASSWORD,Config.ORG1);
|
||||
Logger.getLogger(TestQuery.class.getName()).log(Level.INFO, "adminContext Enrollement : "+adminContext.getEnrollment().toString());
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void TestAQueryChainCode() throws Exception {
|
||||
// Test query for user a on blockchain
|
||||
|
@ -54,4 +75,23 @@ public class TestQuery {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void TestBQuery() throws Exception {
|
||||
try{
|
||||
UserContext userContext = new UserContext();
|
||||
userContext.setName(Config.ADMIN);
|
||||
userContext.setAffiliation(Config.ORG1);
|
||||
userContext.setMspId(Config.ORG1_MSP);
|
||||
|
||||
FabriClientWrapper client = new FabriClientWrapper(userContext);
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public class UtilTest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBwriteUserContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
|
@ -58,4 +59,5 @@ public class UtilTest {
|
|||
Logger.getLogger(UtilTest.class.getName()).log(Level.INFO, "UserContext is : "+uc.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class CAClientWrapper {
|
|||
//Method to enroll admin and save his info
|
||||
public UserContext enrollAdmin(Context context, String name, String secret, String org) throws Exception {
|
||||
UserContext adminContext;
|
||||
adminContext = Util.readUserContext(context,name,secret);
|
||||
adminContext = Util.readUserContext(context,org,name);
|
||||
if(adminContext!=null){
|
||||
Logger.getLogger(CAClientWrapper.class.getName()).log(Level.WARNING, "Admin already enrolled, skip");
|
||||
return adminContext;
|
||||
|
|
|
@ -10,7 +10,7 @@ public class Config {
|
|||
|
||||
public static final String ADMIN_PASSWORD = "AdminOrg1Pwd";
|
||||
|
||||
public static final String CA_ORG1_URL = "vps577432.ovh.net:7054";
|
||||
public static final String CA_ORG1_URL = "http://vps577432.ovh.net:7054";
|
||||
|
||||
public static final String ORDERER_URL = "vps577432.ovh.net:7050";
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||
|
||||
import com.example.monnthic.monnethicmobile.R;
|
||||
|
||||
import org.hyperledger.fabric.sdk.NetworkConfig;
|
||||
//import org.hyperledger.fabric.sdk.NetworkConfig;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
Loading…
Reference in a new issue