This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from iden3/feature/android-4
Feature/android 4
- Loading branch information
Showing
17 changed files
with
1,014 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
buildscript { | ||
ext { | ||
iden3mobile_version = 'v0.0.1-beta12' | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.2" | ||
ndkVersion "20.0.5594570" | ||
|
||
defaultConfig { | ||
applicationId "com.iden3.coreapiintegration" | ||
minSdkVersion 19 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
|
||
// Infura config | ||
Properties infuraProperties = new Properties() | ||
InputStream ins = new FileInputStream("infura.properties") | ||
infuraProperties.load(ins) | ||
ins.close() | ||
buildConfigField("String", "INFURA_URL", infuraProperties['url']) | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = uri("https://maven.pkg.github.com/iden3/iden3-mobile") | ||
credentials { | ||
Properties githubProperties = new Properties() | ||
InputStream ins = new FileInputStream("github.properties") | ||
githubProperties.load(ins) | ||
ins.close() | ||
username = githubProperties['username'] | ||
password = githubProperties['apikey'] | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'androidx.core:core-ktx:1.2.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
|
||
androidTestImplementation 'androidx.test:core:1.2.0' | ||
androidTestImplementation 'androidx.test:core-ktx:1.2.0' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.1' | ||
androidTestImplementation 'androidx.test:runner:1.2.0' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
androidTestImplementation(project(path: ':iden3coreapi')) { | ||
transitive = true | ||
} | ||
androidTestImplementation "com.iden3:iden3mobile:$iden3mobile_version" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
152 changes: 152 additions & 0 deletions
152
...egration/src/androidTest/java/com/iden3/coreapiintegration/Iden3CoreAPInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package com.iden3.coreapiintegration | ||
|
||
import android.content.Context | ||
import android.util.Log | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import com.iden3.coreapiintegration.test.BuildConfig | ||
import com.iden3.iden3coreapi.Iden3CoreAPI | ||
import iden3mobile.CallbackRequestClaim | ||
import org.junit.Assert.* | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.ExpectedException | ||
import org.junit.runner.RunWith | ||
import java.io.File | ||
import java.time.Instant | ||
|
||
/** | ||
* Iden3CoreAPI local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class Iden3CoreAPInstrumentedTest { | ||
|
||
private val web3Url = BuildConfig.INFURA_URL | ||
private val issuerUrl = "http://167.172.104.160:6100/api/unstable" | ||
private val verifierUrl = "http://167.172.104.160:6200/api/unstable" | ||
private lateinit var instrumentationCtx: Context | ||
private lateinit var storePath: String | ||
private lateinit var iden3CoreAPI: Iden3CoreAPI | ||
|
||
@Rule | ||
@JvmField | ||
val expectedException: ExpectedException = ExpectedException.none() | ||
|
||
@Before | ||
fun setup() { | ||
instrumentationCtx = InstrumentationRegistry.getInstrumentation().targetContext | ||
storePath = instrumentationCtx.filesDir.absolutePath | ||
iden3CoreAPI = Iden3CoreAPI() | ||
} | ||
|
||
@Test | ||
fun testInitializeAPISuccess() { | ||
assertEquals(true, initializeAPI()) | ||
} | ||
|
||
@Test | ||
fun testCreateIdentitySuccess() { | ||
val isInitialized = initializeAPI() | ||
if (isInitialized) { | ||
val identity = iden3CoreAPI.createIdentity("alias", "password") | ||
assertNotEquals(identity, null) | ||
iden3CoreAPI.stopIdentity(identity!!) | ||
} else { | ||
assert(false) | ||
} | ||
} | ||
|
||
@Test | ||
fun testLoadIdentitySuccess() { | ||
val isInitialized = initializeAPI() | ||
if (isInitialized) { | ||
if (File("$storePath/alias").exists()) { | ||
val identityLoaded = iden3CoreAPI.loadIdentity("alias", "password") | ||
assertNotEquals(identityLoaded, null) | ||
iden3CoreAPI.stopIdentity(identityLoaded!!) | ||
} else { | ||
val identityCreated = iden3CoreAPI.createIdentity("alias", "password") | ||
iden3CoreAPI.stopIdentity(identityCreated!!) | ||
if (File("$storePath/alias").exists()) { | ||
val identityLoaded = iden3CoreAPI.loadIdentity("alias", "password") | ||
assertNotEquals(identityLoaded, null) | ||
iden3CoreAPI.stopIdentity(identityLoaded!!) | ||
} else { | ||
assert(false) | ||
} | ||
} | ||
} else { | ||
assert(false) | ||
} | ||
} | ||
|
||
@Test | ||
fun testRequestClaimSuccess() { | ||
val isInitialized = initializeAPI() | ||
if (isInitialized) { | ||
val identity = iden3CoreAPI.createIdentity("alias", "password") | ||
if (null != identity) { | ||
val ticket = iden3CoreAPI.requestClaim(identity,"${Instant.now()}", null) | ||
assertNotEquals(ticket, null) | ||
iden3CoreAPI.stopIdentity(identity) | ||
} else { | ||
assert(false) | ||
} | ||
} else { | ||
assert(false) | ||
} | ||
} | ||
|
||
@Test | ||
fun testRequestClaimWithCallbackSuccess() { | ||
val isInitialized = initializeAPI() | ||
if (isInitialized) { | ||
val identity = iden3CoreAPI.createIdentity("alias", "password") | ||
if (null != identity) { | ||
var isFinished = false | ||
iden3CoreAPI.requestClaim(identity,"${Instant.now()}", | ||
CallbackRequestClaim { ticket, exception -> | ||
isFinished = true | ||
Log.i("testRequestClaimWithCallbackSuccess", "Ticket: $ticket") | ||
iden3CoreAPI.stopIdentity(identity) | ||
assertNotEquals(null, ticket) | ||
assertEquals(null, exception) | ||
}) | ||
// Wait for callback | ||
while (!isFinished){ | ||
Log.i("testRequestClaimWithCallbackSuccess","Waiting for request claim ticket") | ||
Thread.sleep(1000) | ||
} | ||
} else { | ||
assert(false) | ||
} | ||
} else { | ||
assert(false) | ||
} | ||
} | ||
|
||
/*@Test | ||
fun testProveClaimSuccess() { | ||
val isInitialized = initializeAPI() | ||
if (isInitialized) { | ||
val identity = iden3CoreAPI.createIdentity("alias", "password") | ||
if (null != identity) { | ||
val ticket = iden3CoreAPI.proveClaim(identity,"${Instant.now()}", null) | ||
assertNotEquals(ticket, null) | ||
iden3CoreAPI.stopIdentity(identity) | ||
} else { | ||
assert(false) | ||
} | ||
} else { | ||
assert(false) | ||
} | ||
}*/ | ||
|
||
private fun initializeAPI() : Boolean { | ||
return iden3CoreAPI.initializeAPI(web3Url, issuerUrl, verifierUrl, storePath, 10000) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.iden3.coreapiintegration"> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<application | ||
android:supportsRtl="true"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
11 changes: 11 additions & 0 deletions
11
android/coreapiintegration/src/main/java/com/iden3/coreapiintegration/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.iden3.coreapiintegration | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.