
14 changed files with 2380 additions and 334 deletions
@ -0,0 +1,10 @@ |
|||
package com.pep.k9; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
/** |
|||
* Created by arturo on 15/11/16. |
|||
*/ |
|||
public class PEpTest { |
|||
|
|||
} |
@ -1,23 +1,27 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
|||
package="com.pep.k9" > |
|||
package="com.pep.k9"> |
|||
|
|||
<uses-permission android:name="android.permission.INTERNET" /> |
|||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
|||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
|||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
|||
|
|||
<application |
|||
android:allowBackup="true" |
|||
android:icon="@mipmap/ic_launcher" |
|||
android:label="@string/app_name" |
|||
android:theme="@style/AppTheme" > |
|||
android:theme="@style/AppTheme"> |
|||
<activity |
|||
android:name=".MainActivity" |
|||
android:label="@string/app_name" > |
|||
android:label="@string/app_name"> |
|||
<intent-filter> |
|||
<action android:name="android.intent.action.MAIN" /> |
|||
|
|||
<category android:name="android.intent.category.LAUNCHER" /> |
|||
</intent-filter> |
|||
</activity> |
|||
<activity android:name=".UnitActivity"></activity> |
|||
</application> |
|||
|
|||
</manifest> |
|||
</manifest> |
File diff suppressed because it is too large
@ -0,0 +1,46 @@ |
|||
package com.pep.k9; |
|||
|
|||
import org.pEp.jniadapter.Engine; |
|||
import org.pEp.jniadapter.Identity; |
|||
import org.pEp.jniadapter.Message; |
|||
|
|||
import java.util.Vector; |
|||
|
|||
public class PEpUnitaryStuff { |
|||
public static void main (String args[]) { |
|||
try { |
|||
shouldDoSomeStuff(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
public static void shouldDoSomeStuff() throws Exception { |
|||
Engine engine; |
|||
engine = new Engine(); |
|||
|
|||
Message msg = new Message(); |
|||
msg.setFrom(new Identity()); |
|||
|
|||
Vector<Identity> to = new Vector<>(); |
|||
to.add(new Identity()); |
|||
msg.setTo(to); |
|||
|
|||
msg.setShortmsg("hello, world"); |
|||
String message = "this is a test"; |
|||
msg.setLongmsg(message); |
|||
|
|||
msg.setDir(Message.Direction.Outgoing); |
|||
|
|||
Vector<Identity> cc = new Vector<>(); |
|||
cc.add(new Identity()); |
|||
msg.setCc(cc); |
|||
|
|||
Message encriptedMessage = engine.encrypt_message(msg, null); |
|||
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage); |
|||
|
|||
if (!decrypt_message_return.dst.getLongmsg().equals(message)) { |
|||
throw new RuntimeException("FAILED"); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,280 @@ |
|||
package com.pep.k9; |
|||
|
|||
import android.content.res.AssetManager; |
|||
import android.support.annotation.NonNull; |
|||
import android.support.v7.app.AppCompatActivity; |
|||
import android.os.Bundle; |
|||
|
|||
import org.pEp.jniadapter.Blob; |
|||
import org.pEp.jniadapter.Engine; |
|||
import org.pEp.jniadapter.Identity; |
|||
import org.pEp.jniadapter.Message; |
|||
import org.pEp.jniadapter.Pair; |
|||
import org.pEp.jniadapter.Rating; |
|||
import org.pEp.jniadapter.pEpException; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.util.ArrayList; |
|||
import java.util.Vector; |
|||
|
|||
public class UnitActivity extends AppCompatActivity { |
|||
|
|||
@Override |
|||
protected void onCreate(Bundle savedInstanceState) { |
|||
super.onCreate(savedInstanceState); |
|||
setContentView(R.layout.activity_unit); |
|||
|
|||
try { |
|||
messageAfterDecriptionShouldBeTheSame(); |
|||
messageAfterDecriptionWithoutKeyShouldKeepBreaks(); |
|||
messageAfterDecriptionShouldKeepBreaks(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
public void messageAfterDecriptionWithoutKeyShouldKeepBreaks() throws Exception { |
|||
Engine engine; |
|||
engine = new Engine(); |
|||
|
|||
Identity alice = loadAliceFromEngine(engine); |
|||
|
|||
Identity bob = loadDummyBobFromEngine(engine); |
|||
|
|||
// message
|
|||
Message msg = new Message(); |
|||
msg.setFrom(alice); |
|||
|
|||
Vector<Identity> to = new Vector<>(); |
|||
to.add(bob); |
|||
msg.setTo(to); |
|||
|
|||
msg.setShortmsg("hello, world"); |
|||
msg.setLongmsg("thisis\nastest"); |
|||
|
|||
msg.setDir(Message.Direction.Outgoing); |
|||
|
|||
Vector<Identity> cc = new Vector<>(); |
|||
cc.add(alice); |
|||
msg.setCc(cc); |
|||
|
|||
ArrayList<Pair<String, String>> pairs = new ArrayList<>(); |
|||
pairs.add(new Pair<>("Received", "in time")); |
|||
pairs.add(new Pair<>("X-Foobaz", "of course")); |
|||
msg.setOptFields(pairs); |
|||
|
|||
Message encriptedMessage = null; |
|||
encriptedMessage = encryptMessageOnEngine(engine, msg); |
|||
|
|||
Vector<Blob> attachments = encriptedMessage.getAttachments(); |
|||
|
|||
Engine.decrypt_message_Return result = null; |
|||
result = decryptMessageOnEngine(engine, encriptedMessage); |
|||
|
|||
engine.close(); |
|||
|
|||
if (!result.dst.getLongmsg().equals(msg.getLongmsg())) { |
|||
throw new RuntimeException("FAILED: " +result.dst.getLongmsg()+" not equals to "+msg.getLongmsg()); |
|||
} |
|||
} |
|||
|
|||
public void messageAfterDecriptionShouldKeepBreaks() throws Exception { |
|||
Engine engine; |
|||
engine = new Engine(); |
|||
|
|||
Identity alice = loadAliceFromEngine(engine); |
|||
|
|||
Identity bob = loadBobFromEngine(engine); |
|||
|
|||
// message
|
|||
Message msg = new Message(); |
|||
msg.setFrom(alice); |
|||
|
|||
Vector<Identity> to = new Vector<>(); |
|||
to.add(bob); |
|||
msg.setTo(to); |
|||
|
|||
msg.setShortmsg("hello, world"); |
|||
msg.setLongmsg("thisis\nastest"); |
|||
|
|||
msg.setDir(Message.Direction.Outgoing); |
|||
|
|||
Vector<Identity> cc = new Vector<>(); |
|||
cc.add(alice); |
|||
msg.setCc(cc); |
|||
|
|||
ArrayList<Pair<String, String>> pairs = new ArrayList<>(); |
|||
pairs.add(new Pair<>("Received", "in time")); |
|||
pairs.add(new Pair<>("X-Foobaz", "of course")); |
|||
msg.setOptFields(pairs); |
|||
|
|||
Message encriptedMessage = null; |
|||
encriptedMessage = encryptMessageOnEngine(engine, msg); |
|||
|
|||
Vector<Blob> attachments = encriptedMessage.getAttachments(); |
|||
|
|||
Engine.decrypt_message_Return result = null; |
|||
result = decryptMessageOnEngine(engine, encriptedMessage); |
|||
|
|||
engine.close(); |
|||
|
|||
if (!result.dst.getLongmsg().equals(msg.getLongmsg())) { |
|||
throw new RuntimeException("FAILED: " +result.dst.getLongmsg()+" not equals to "+msg.getLongmsg()); |
|||
} |
|||
} |
|||
|
|||
public void messageAfterDecriptionShouldBeTheSame() throws Exception { |
|||
Engine engine; |
|||
engine = new Engine(); |
|||
|
|||
Identity alice = loadAliceFromEngine(engine); |
|||
|
|||
Identity bob = loadBobFromEngine(engine); |
|||
|
|||
// message
|
|||
Message msg = setupMessage(alice, bob); |
|||
|
|||
ArrayList<Pair<String, String>> pairs = new ArrayList<>(); |
|||
pairs.add(new Pair<>("Received", "in time")); |
|||
pairs.add(new Pair<>("X-Foobaz", "of course")); |
|||
msg.setOptFields(pairs); |
|||
|
|||
Message encriptedMessage = null; |
|||
encriptedMessage = encryptMessageOnEngine(engine, msg); |
|||
|
|||
Vector<Blob> attachments = encriptedMessage.getAttachments(); |
|||
|
|||
Engine.decrypt_message_Return result = null; |
|||
result = decryptMessageOnEngine(engine, encriptedMessage); |
|||
|
|||
engine.close(); |
|||
|
|||
if (!result.dst.getLongmsg().equals(msg.getLongmsg())) { |
|||
throw new RuntimeException("FAILED: " +result.dst.getLongmsg()+" not equals to "+msg.getLongmsg()); |
|||
} |
|||
} |
|||
|
|||
private Message setupMessage(Identity alice, Identity bob) { |
|||
Message msg = new Message(); |
|||
msg.setFrom(alice); |
|||
|
|||
Vector<Identity> to = new Vector<>(); |
|||
to.add(bob); |
|||
msg.setTo(to); |
|||
|
|||
msg.setShortmsg("hello, world"); |
|||
msg.setLongmsg("this is a test"); |
|||
|
|||
msg.setDir(Message.Direction.Outgoing); |
|||
|
|||
Vector<Identity> cc = new Vector<>(); |
|||
cc.add(alice); |
|||
msg.setCc(cc); |
|||
|
|||
return msg; |
|||
} |
|||
|
|||
private Engine.decrypt_message_Return decryptMessageOnEngine(Engine engine, Message encriptedMessage) throws pEpException { |
|||
long lastTime = System.currentTimeMillis(); |
|||
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage); |
|||
return decrypt_message_return; |
|||
} |
|||
|
|||
private Message encryptMessageOnEngine(Engine engine, Message msg) throws pEpException { |
|||
long lastTime = System.currentTimeMillis(); |
|||
Message message = engine.encrypt_message(msg, null); |
|||
return message; |
|||
} |
|||
|
|||
private Identity loadBobFromEngine(Engine engine) throws IOException { |
|||
//
|
|||
// Other peers :
|
|||
// pEp Test Bob (test key, don't use) <pep.test.bob@pep-project.org>
|
|||
// C9C2EE39
|
|||
// 59BFF488C9C2EE39
|
|||
importKeyFromEngine(engine, "0xC9C2EE39.asc"); |
|||
|
|||
Identity bob = new Identity(); |
|||
bob.username = "bob Test"; |
|||
bob.address = "pep.test.bob@pep-project.org"; |
|||
bob.user_id = "112"; |
|||
bob.fpr = "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39"; |
|||
|
|||
updateIdentityOnEngine(engine, bob); |
|||
return bob; |
|||
} |
|||
|
|||
private Identity loadDummyBobFromEngine(Engine engine) throws IOException { |
|||
//
|
|||
// Other peers :
|
|||
// pEp Test Bob (test key, don't use) <pep.test.bob@pep-project.org>
|
|||
// C9C2EE39
|
|||
// 59BFF488C9C2EE39
|
|||
|
|||
Identity bob = new Identity(); |
|||
bob.username = "bob Test"; |
|||
bob.address = "pep.test.bob@pep-project.org"; |
|||
bob.user_id = "112"; |
|||
|
|||
updateIdentityOnEngine(engine, bob); |
|||
return bob; |
|||
} |
|||
|
|||
private void updateIdentityOnEngine(Engine engine, Identity identity) { |
|||
long lastTime = System.currentTimeMillis(); |
|||
engine.updateIdentity(identity); |
|||
} |
|||
|
|||
@NonNull |
|||
private Identity loadAliceFromEngine(Engine engine) throws IOException { |
|||
// Our test user :
|
|||
// pEp Test Alice (test key don't use) <pep.test.alice@pep-project.org>
|
|||
// 6FF00E97
|
|||
// A9411D176FF00E97
|
|||
importKeyFromEngine(engine, "6FF00E97_sec.asc"); |
|||
|
|||
Identity alice = new Identity(); |
|||
alice.username = "Alice Test"; |
|||
alice.address = "pep.test.alice@pep-project.org"; |
|||
alice.user_id = "pEp_own_userId"; |
|||
alice.me = true; |
|||
alice.fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97"; |
|||
|
|||
long lastTime = System.currentTimeMillis(); |
|||
myselfInEngine(engine, alice); |
|||
|
|||
return alice; |
|||
} |
|||
|
|||
private void importKeyFromEngine(Engine engine, String filename) throws IOException { |
|||
long lastTime = System.currentTimeMillis(); |
|||
engine.importKey(LoadAssetAsString(filename)); |
|||
} |
|||
|
|||
private String LoadAssetAsString(String fname) throws IOException { |
|||
// byte buffer into a string
|
|||
return new String(LoadAssetAsBuffer(fname)); |
|||
} |
|||
|
|||
private byte[] LoadAssetAsBuffer(String fname) throws IOException { |
|||
AssetManager assetManager = getAssets(); |
|||
InputStream input; |
|||
|
|||
input = assetManager.open(fname); |
|||
|
|||
int size = input.available(); |
|||
byte[] buffer = new byte[size]; |
|||
input.read(buffer); |
|||
input.close(); |
|||
|
|||
// byte buffer
|
|||
return buffer; |
|||
|
|||
} |
|||
|
|||
private Identity myselfInEngine(Engine engine, Identity identity) { |
|||
Identity myself = engine.myself(identity); |
|||
return myself; |
|||
} |
|||
} |
@ -1,103 +1,396 @@ |
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" |
|||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" |
|||
android:paddingRight="@dimen/activity_horizontal_margin" |
|||
android:paddingTop="@dimen/activity_vertical_margin" |
|||
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> |
|||
|
|||
<!--//testPEpTypes();--> |
|||
<!--//testPEpAliceBobJohn();--> |
|||
<!--//testKeyserverLookup();--> |
|||
<!--testKeyGen();--> |
|||
<LinearLayout |
|||
android:orientation="vertical" |
|||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent"> |
|||
<LinearLayout android:id="@+id/content" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="vertical" |
|||
tools:context=".MainActivity"> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="KeyGen" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/bRunGenKey" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:layout_alignParentLeft="true" |
|||
android:layout_alignParentStart="true"> |
|||
android:layout_alignParentStart="true" |
|||
android:orientation="vertical"> |
|||
|
|||
<LinearLayout |
|||
android:orientation="horizontal" |
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content"> |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" |
|||
android:layout_weight="1" |
|||
android:text="pEp Types" |
|||
android:layout_weight="1"/> |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
<Button |
|||
android:id="@+id/bRunTypes" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:text="Run" |
|||
android:id="@+id/bRunTypes" |
|||
android:layout_weight="1"/> |
|||
</LinearLayout> |
|||
<LinearLayout |
|||
android:orientation="horizontal" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content"> |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" |
|||
android:text="pEp Alice Bob John" |
|||
android:layout_weight="1"/> |
|||
android:layout_weight="1" |
|||
android:text="Server Lookup" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
<Button |
|||
android:id="@+id/bRunServerLookup" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:text="Run" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Encrypt and decreypt" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/encrypt_and_decrypt" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Encrypt and decreypt without key" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/encrypt_and_decrypt_without_key" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Ratings" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/ratings" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Integration test" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/bRunAliceBob" |
|||
android:layout_weight="1"/> |
|||
</LinearLayout> |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:orientation="horizontal" |
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content"> |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" |
|||
android:text="Server Lookup" |
|||
android:layout_weight="1"/> |
|||
android:layout_weight="1" |
|||
android:text="Add to blacklist + new key" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
<Button |
|||
android:id="@+id/black_list" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:text="Run" |
|||
android:id="@+id/bRunServerLookup" |
|||
android:layout_weight="1"/> |
|||
</LinearLayout> |
|||
<LinearLayout |
|||
android:orientation="horizontal" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content"> |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" |
|||
android:text="KeyGen" |
|||
android:layout_weight="1"/> |
|||
android:layout_weight="1" |
|||
android:text="Blacklist + send" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
<Button |
|||
android:id="@+id/black_list_and_send" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:text="Run" |
|||
android:id="@+id/bRunGenKey" |
|||
android:layout_weight="1"/> |
|||
</LinearLayout> |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
</LinearLayout> |
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Blacklist + delete" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
</RelativeLayout> |
|||
<Button |
|||
android:id="@+id/black_list_and_delete" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Unencrypt subject" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/unencrypted_subject" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Passive mode" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/passive_mode" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="enc + dec message to myself" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/message_me" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Message from me - green" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/message_from_me_green" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="outgoing color" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/outgoing_color" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="identity" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/identity_rating" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Deblacklist rating" |
|||
android:textAppearance="?android:attr/textAppearanceMedium" /> |
|||
|
|||
<Button |
|||
android:id="@+id/deblacklist" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="Run" /> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
<EditText |
|||
android:id="@+id/times_to_test" |
|||
android:layout_width="30dp" |
|||
android:layout_height="wrap_content" |
|||
android:text="1" |
|||
android:inputType="textEmailAddress" /> |
|||
<Button |
|||
android:id="@+id/test_everything" |
|||
style="?android:attr/buttonStyleSmall" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_weight="1" |
|||
android:text="TEST EVERYTHING" /> |
|||
</LinearLayout> |
|||
|
|||
</LinearLayout> |
|||
</LinearLayout> |
|||
</ScrollView> |
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:id="@+id/activity_unit" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:paddingBottom="@dimen/activity_vertical_margin" |
|||
android:paddingLeft="@dimen/activity_horizontal_margin" |
|||
android:paddingRight="@dimen/activity_horizontal_margin" |
|||
android:paddingTop="@dimen/activity_vertical_margin" |
|||
tools:context="com.pep.k9.UnitActivity"> |
|||
|
|||
</RelativeLayout> |
@ -1,6 +1,8 @@ |
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> |
|||
<item android:id="@+id/action_settings" android:title="@string/action_settings" |
|||
<item android:id="@+id/action_settings" android:title="Refresh" |
|||
android:orderInCategory="100" app:showAsAction="never" /> |
|||
<item android:id="@+id/action_unitary" android:title="Do More things" |
|||
android:orderInCategory="100" app:showAsAction="never" /> |
|||
</menu> |
|||
|
@ -0,0 +1,10 @@ |
|||
package com.pep.k9; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
/** |
|||
* Created by arturo on 15/11/16. |
|||
*/ |
|||
public class MainActivityTest { |
|||
|
|||
} |
@ -0,0 +1,49 @@ |
|||
package com.pep.k9; |
|||
|
|||
import org.junit.Assert; |
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
import org.pEp.jniadapter.Engine; |
|||
import org.pEp.jniadapter.Identity; |
|||
import org.pEp.jniadapter.Message; |
|||
|
|||
import java.util.Vector; |
|||
|
|||
/** |
|||
* Created by arturo on 15/11/16. |
|||
*/ |
|||
public class UnitaryTest { |
|||
|
|||
@Before |
|||
public void setUp() throws Exception { |
|||
|
|||
} |
|||
|
|||
@Test |
|||
public void shouldDoSomeStuff() throws Exception { |
|||
Engine engine; |
|||
engine = new Engine(); |
|||
|
|||
Message msg = new Message(); |
|||
msg.setFrom(new Identity()); |
|||
|
|||
Vector<Identity> to = new Vector<>(); |
|||
to.add(new Identity()); |
|||
msg.setTo(to); |
|||
|
|||
msg.setShortmsg("hello, world"); |
|||
String message = "this is a test"; |
|||
msg.setLongmsg(message); |
|||
|
|||
msg.setDir(Message.Direction.Outgoing); |
|||
|
|||
Vector<Identity> cc = new Vector<>(); |
|||
cc.add(new Identity()); |
|||
msg.setCc(cc); |
|||
|
|||
Message encriptedMessage = engine.encrypt_message(msg, null); |
|||
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage); |
|||
|
|||
Assert.assertTrue(decrypt_message_return.dst.getLongmsg().equals(message)); |
|||
} |
|||
} |
Loading…
Reference in new issue