mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Merge remote-tracking branch 'origin/master' into v/eventbus
This commit is contained in:
commit
244f92ed57
@ -14,6 +14,5 @@ before_install:
|
|||||||
- ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --force --filter build-tools-22.0.1,build-tools-21.1.2,build-tools-21.1.1,build-tools-19.1.0,android-22,android-21,android-19,platform-tools,extra-android-support,extra-android-m2repository
|
- ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --force --filter build-tools-22.0.1,build-tools-21.1.2,build-tools-21.1.1,build-tools-19.1.0,android-22,android-21,android-19,platform-tools,extra-android-support,extra-android-m2repository
|
||||||
install: echo "Installation done"
|
install: echo "Installation done"
|
||||||
script:
|
script:
|
||||||
- ./gradlew assemble -S -q
|
- ./gradlew testDebug jacocoTestReport coveralls --info
|
||||||
- ./gradlew --info OpenKeychain-Test:testDebug
|
|
||||||
|
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
// NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information
|
|
||||||
classpath 'com.novoda:gradle-android-test-plugin:0.10.4'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'java'
|
|
||||||
apply plugin: 'android-test'
|
|
||||||
apply plugin: 'jacoco'
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testCompile 'junit:junit:4.11'
|
|
||||||
testCompile 'com.google.android:android:4.1.1.4'
|
|
||||||
testCompile('com.squareup:fest-android:1.0.8') { exclude module: 'support-v4' }
|
|
||||||
testCompile 'org.apache.maven:maven-ant-tasks:2.1.3'
|
|
||||||
testCompile ('org.robolectric:robolectric:2.4') {
|
|
||||||
exclude module: 'classworlds'
|
|
||||||
exclude module: 'maven-artifact'
|
|
||||||
exclude module: 'maven-artifact-manager'
|
|
||||||
exclude module: 'maven-error-diagnostics'
|
|
||||||
exclude module: 'maven-model'
|
|
||||||
exclude module: 'maven-plugin-registry'
|
|
||||||
exclude module: 'maven-profile'
|
|
||||||
exclude module: 'maven-project'
|
|
||||||
exclude module: 'maven-settings'
|
|
||||||
exclude module: 'nekohtml'
|
|
||||||
exclude module: 'plexus-container-default'
|
|
||||||
exclude module: 'plexus-interpolation'
|
|
||||||
exclude module: 'plexus-utils'
|
|
||||||
exclude module: 'support-v4' // crazy but my android studio don't like this dependency and to fix it remove .idea and re import project
|
|
||||||
exclude module: 'wagon-file'
|
|
||||||
exclude module: 'wagon-http-lightweight'
|
|
||||||
exclude module: 'wagon-http-shared'
|
|
||||||
exclude module: 'wagon-provider-api'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
exclude '**/*$*'
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
projectUnderTest ':OpenKeychain'
|
|
||||||
}
|
|
||||||
|
|
||||||
jacoco {
|
|
||||||
toolVersion = "0.7.2.201409121644"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def coverageSourceDirs = [
|
|
||||||
'../OpenKeychain/src/main/java',
|
|
||||||
'../OpenKeychain/src/gen',
|
|
||||||
'../OpenKeychain/build/source/apt/debug',
|
|
||||||
'../OpenKeychain/build/source/generated/buildConfig/debug',
|
|
||||||
'../OpenKeychain/build/source/generated/r/debug'
|
|
||||||
]
|
|
||||||
|
|
||||||
jacocoTestReport {
|
|
||||||
reports {
|
|
||||||
xml.enabled = true
|
|
||||||
html.destination "${buildDir}/jacocoHtml"
|
|
||||||
}
|
|
||||||
// class R is used, but usage will not be covered, so ignore this class from report
|
|
||||||
classDirectories = fileTree(dir: '../OpenKeychain/build/intermediates/classes/debug/org/sufficientlysecure/keychain', exclude: [ 'R*.class' ])
|
|
||||||
additionalSourceDirs = files(coverageSourceDirs)
|
|
||||||
executionData = files('build/jacoco/testDebug.exec')
|
|
||||||
}
|
|
||||||
|
|
||||||
// new workaround to force add custom output dirs for android studio
|
|
||||||
task addTest {
|
|
||||||
def file = file(project.name + ".iml")
|
|
||||||
doLast {
|
|
||||||
try {
|
|
||||||
def parsedXml = (new XmlParser()).parse(file)
|
|
||||||
def node = parsedXml.component[1]
|
|
||||||
def outputNode = parsedXml.component[1].output[0]
|
|
||||||
def outputTestNode = parsedXml.component[1].'output-test'[0]
|
|
||||||
def rewrite = false
|
|
||||||
|
|
||||||
new Node(node, 'sourceFolder', ['url': 'file://$MODULE_DIR$/' + "${it}", 'isTestSource': "true"])
|
|
||||||
|
|
||||||
if(outputNode == null) {
|
|
||||||
new Node(node, 'output', ['url': 'file://$MODULE_DIR$/build/resources/testDebug'])
|
|
||||||
} else {
|
|
||||||
if(outputNode.attributes['url'] != 'file://$MODULE_DIR$/build/resources/testDebug') {
|
|
||||||
outputNode.attributes = ['url': 'file://$MODULE_DIR$/build/resources/testDebug']
|
|
||||||
rewrite = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(outputTestNode == null) {
|
|
||||||
new Node(node, 'output-test', ['url': 'file://$MODULE_DIR$/build/test-classes/debug'])
|
|
||||||
} else {
|
|
||||||
if(outputTestNode.attributes['url'] != 'file://$MODULE_DIR$/build/test-classes/debug') {
|
|
||||||
outputTestNode.attributes = ['url': 'file://$MODULE_DIR$/build/test-classes/debug']
|
|
||||||
rewrite = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rewrite) {
|
|
||||||
def writer = new StringWriter()
|
|
||||||
new XmlNodePrinter(new PrintWriter(writer)).print(parsedXml)
|
|
||||||
file.text = writer.toString()
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
// iml not found, common on command line only builds
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// always do the addtest on prebuild
|
|
||||||
gradle.projectsEvaluated {
|
|
||||||
testDebugClasses.dependsOn(addTest)
|
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'witness'
|
apply plugin: 'witness'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
|
apply plugin: 'com.github.kt3k.coveralls'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information
|
// NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information
|
||||||
@ -11,7 +13,14 @@ dependencies {
|
|||||||
compile 'com.android.support:recyclerview-v7:22.1.0'
|
compile 'com.android.support:recyclerview-v7:22.1.0'
|
||||||
compile 'com.android.support:cardview-v7:22.1.0'
|
compile 'com.android.support:cardview-v7:22.1.0'
|
||||||
|
|
||||||
// UI testing libs
|
// Unit tests in the local JVM with Robolectric
|
||||||
|
// https://developer.android.com/training/testing/unit-testing/local-unit-tests.html
|
||||||
|
// https://github.com/nenick/AndroidStudioAndRobolectric
|
||||||
|
// http://www.vogella.com/tutorials/Robolectric/article.html
|
||||||
|
testCompile 'junit:junit:4.12'
|
||||||
|
testCompile 'org.robolectric:robolectric:3.0-rc3'
|
||||||
|
|
||||||
|
// UI testing with Espresso
|
||||||
androidTestCompile 'com.android.support.test:runner:0.2'
|
androidTestCompile 'com.android.support.test:runner:0.2'
|
||||||
androidTestCompile 'com.android.support.test:rules:0.2'
|
androidTestCompile 'com.android.support.test:rules:0.2'
|
||||||
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
|
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
|
||||||
@ -98,7 +107,9 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
|
versionCode 32300
|
||||||
|
versionName "3.2.3"
|
||||||
|
applicationId "org.sufficientlysecure.keychain"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +122,26 @@ android {
|
|||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
|
||||||
|
// Reference them in the java files with e.g. BuildConfig.ACCOUNT_TYPE.
|
||||||
|
buildConfigField "String", "ACCOUNT_TYPE", "\"org.sufficientlysecure.keychain.account\""
|
||||||
|
|
||||||
|
// Reference them in .xml files.
|
||||||
|
resValue "string", "account_type", "org.sufficientlysecure.keychain.account"
|
||||||
|
}
|
||||||
|
|
||||||
|
debug {
|
||||||
|
applicationIdSuffix ".debug"
|
||||||
|
|
||||||
|
// Reference them in the java files with e.g. BuildConfig.ACCOUNT_TYPE.
|
||||||
|
buildConfigField "String", "ACCOUNT_TYPE", "\"org.sufficientlysecure.keychain.debug.account\""
|
||||||
|
|
||||||
|
// Reference them in .xml files.
|
||||||
|
resValue "string", "account_type", "org.sufficientlysecure.keychain.debug.account"
|
||||||
|
|
||||||
|
// Disabled: only works for androidTest not test!
|
||||||
|
// Enable code coverage (Jacoco)
|
||||||
|
//testCoverageEnabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +194,37 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task jacocoTestReport(type:JacocoReport) {
|
||||||
|
group = "Reporting"
|
||||||
|
description = "Generate Jacoco coverage reports"
|
||||||
|
|
||||||
|
classDirectories = fileTree(
|
||||||
|
dir: "${buildDir}/intermediates/classes/debug",
|
||||||
|
excludes: ['**/R.class',
|
||||||
|
'**/R$*.class',
|
||||||
|
'**/*$ViewInjector*.*',
|
||||||
|
'**/BuildConfig.*',
|
||||||
|
'**/Manifest*.*']
|
||||||
|
)
|
||||||
|
|
||||||
|
sourceDirectories = files("${buildDir.parent}/src/main/java")
|
||||||
|
additionalSourceDirs = files([
|
||||||
|
"${buildDir}/generated/source/buildConfig/debug",
|
||||||
|
"${buildDir}/generated/source/r/debug"
|
||||||
|
])
|
||||||
|
executionData = files("${buildDir}/jacoco/testDebug.exec")
|
||||||
|
|
||||||
|
reports {
|
||||||
|
xml.enabled = true
|
||||||
|
html.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix for: No report file available: [/home/travis/build/open-keychain/open-keychain/OpenKeychain/build/reports/cobertura/coverage.xml, /home/travis/build/open-keychain/open-keychain/OpenKeychain/build/reports/jacoco/test/jacocoTestReport.xml]
|
||||||
|
coveralls {
|
||||||
|
jacocoReportPath 'build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml'
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: This disables Lint!
|
// NOTE: This disables Lint!
|
||||||
tasks.whenTaskAdded { task ->
|
tasks.whenTaskAdded { task ->
|
||||||
if (task.name.contains('lint')) {
|
if (task.name.contains('lint')) {
|
||||||
|
BIN
OpenKeychain/src/debug/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
OpenKeychain/src/debug/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
BIN
OpenKeychain/src/debug/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
OpenKeychain/src/debug/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
OpenKeychain/src/debug/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
OpenKeychain/src/debug/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
BIN
OpenKeychain/src/debug/res/drawable-xxhdpi/ic_launcher.png
Normal file
BIN
OpenKeychain/src/debug/res/drawable-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
OpenKeychain/src/debug/res/drawable-xxxhdpi/ic_launcher.png
Normal file
BIN
OpenKeychain/src/debug/res/drawable-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -2,9 +2,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="org.sufficientlysecure.keychain"
|
package="org.sufficientlysecure.keychain"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto">
|
||||||
android:versionCode="32300"
|
|
||||||
android:versionName="3.2.3">
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
General remarks
|
General remarks
|
||||||
@ -50,9 +48,9 @@
|
|||||||
android:name="android.hardware.screen.portrait"
|
android:name="android.hardware.screen.portrait"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
|
|
||||||
<permission android:name="org.sufficientlysecure.keychain.WRITE_TEMPORARY_STORAGE" />
|
<permission android:name="${applicationId}.WRITE_TEMPORARY_STORAGE" />
|
||||||
|
|
||||||
<uses-permission android:name="org.sufficientlysecure.keychain.WRITE_TEMPORARY_STORAGE" />
|
<uses-permission android:name="${applicationId}.WRITE_TEMPORARY_STORAGE" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
@ -724,13 +722,10 @@
|
|||||||
<service
|
<service
|
||||||
android:name=".service.KeychainService"
|
android:name=".service.KeychainService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<service
|
|
||||||
android:name=".service.CloudImportService"
|
|
||||||
android:exported="false" />
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name=".provider.KeychainProvider"
|
android:name=".provider.KeychainProvider"
|
||||||
android:authorities="org.sufficientlysecure.keychain.provider"
|
android:authorities="${applicationId}.provider"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<!-- Internal classes of the remote APIs (not exported) -->
|
<!-- Internal classes of the remote APIs (not exported) -->
|
||||||
@ -808,9 +803,9 @@
|
|||||||
<!-- Storage Provider for temporary decrypted files -->
|
<!-- Storage Provider for temporary decrypted files -->
|
||||||
<provider
|
<provider
|
||||||
android:name=".provider.TemporaryStorageProvider"
|
android:name=".provider.TemporaryStorageProvider"
|
||||||
android:authorities="org.sufficientlysecure.keychain.tempstorage"
|
android:authorities="${applicationId}.tempstorage"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:writePermission="org.sufficientlysecure.keychain.WRITE_TEMPORARY_STORAGE" />
|
android:writePermission="${applicationId}.WRITE_TEMPORARY_STORAGE" />
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
@ -31,14 +31,17 @@ public final class Constants {
|
|||||||
public static final boolean DEBUG_LOG_DB_QUERIES = false;
|
public static final boolean DEBUG_LOG_DB_QUERIES = false;
|
||||||
public static final boolean DEBUG_SYNC_REMOVE_CONTACTS = false;
|
public static final boolean DEBUG_SYNC_REMOVE_CONTACTS = false;
|
||||||
|
|
||||||
public static final String TAG = "Keychain";
|
public static final String TAG = DEBUG ? "Keychain D" : "Keychain";
|
||||||
|
|
||||||
public static final String PACKAGE_NAME = "org.sufficientlysecure.keychain";
|
public static final String PACKAGE_NAME = "org.sufficientlysecure.keychain";
|
||||||
|
|
||||||
public static final String ACCOUNT_NAME = "OpenKeychain";
|
public static final String ACCOUNT_NAME = DEBUG ? "OpenKeychain D" : "OpenKeychain";
|
||||||
public static final String ACCOUNT_TYPE = PACKAGE_NAME + ".account";
|
public static final String ACCOUNT_TYPE = BuildConfig.ACCOUNT_TYPE;
|
||||||
public static final String CUSTOM_CONTACT_DATA_MIME_TYPE = "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key";
|
public static final String CUSTOM_CONTACT_DATA_MIME_TYPE = "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key";
|
||||||
|
|
||||||
|
public static final String PROVIDER_AUTHORITY = BuildConfig.APPLICATION_ID + ".provider";
|
||||||
|
public static final String TEMPSTORAGE_AUTHORITY = BuildConfig.APPLICATION_ID + ".tempstorage";
|
||||||
|
|
||||||
// as defined in http://tools.ietf.org/html/rfc3156, section 7
|
// as defined in http://tools.ietf.org/html/rfc3156, section 7
|
||||||
public static final String NFC_MIME = "application/pgp-keys";
|
public static final String NFC_MIME = "application/pgp-keys";
|
||||||
|
|
||||||
|
@ -128,8 +128,6 @@ public class KeychainApplication extends Application {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add OpenKeychain account to Android to link contacts with keys
|
* Add OpenKeychain account to Android to link contacts with keys
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
*/
|
*/
|
||||||
public static void setupAccountAsNeeded(Context context) {
|
public static void setupAccountAsNeeded(Context context) {
|
||||||
try {
|
try {
|
||||||
@ -165,7 +163,7 @@ public class KeychainApplication extends Application {
|
|||||||
int edgeDrawableId = context.getResources().getIdentifier("overscroll_edge", "drawable", "android");
|
int edgeDrawableId = context.getResources().getIdentifier("overscroll_edge", "drawable", "android");
|
||||||
Drawable androidEdge = context.getResources().getDrawable(edgeDrawableId);
|
Drawable androidEdge = context.getResources().getDrawable(edgeDrawableId);
|
||||||
androidEdge.setColorFilter(brandColor, PorterDuff.Mode.SRC_IN);
|
androidEdge.setColorFilter(brandColor, PorterDuff.Mode.SRC_IN);
|
||||||
} catch (Resources.NotFoundException e) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class KeychainContract {
|
|||||||
String PACKAGE_NAME = "package_name"; // foreign key to api_apps.package_name
|
String PACKAGE_NAME = "package_name"; // foreign key to api_apps.package_name
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String CONTENT_AUTHORITY = Constants.PACKAGE_NAME + ".provider";
|
public static final String CONTENT_AUTHORITY = Constants.PROVIDER_AUTHORITY;
|
||||||
|
|
||||||
private static final Uri BASE_CONTENT_URI_INTERNAL = Uri
|
private static final Uri BASE_CONTENT_URI_INTERNAL = Uri
|
||||||
.parse("content://" + CONTENT_AUTHORITY);
|
.parse("content://" + CONTENT_AUTHORITY);
|
||||||
|
@ -45,7 +45,8 @@ public class TemporaryStorageProvider extends ContentProvider {
|
|||||||
private static final String COLUMN_ID = "id";
|
private static final String COLUMN_ID = "id";
|
||||||
private static final String COLUMN_NAME = "name";
|
private static final String COLUMN_NAME = "name";
|
||||||
private static final String COLUMN_TIME = "time";
|
private static final String COLUMN_TIME = "time";
|
||||||
private static final Uri BASE_URI = Uri.parse("content://org.sufficientlysecure.keychain.tempstorage/");
|
public static final String CONTENT_AUTHORITY = Constants.TEMPSTORAGE_AUTHORITY;
|
||||||
|
private static final Uri BASE_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
|
||||||
private static final int DB_VERSION = 2;
|
private static final int DB_VERSION = 2;
|
||||||
|
|
||||||
private static File cacheDir;
|
private static File cacheDir;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
|
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:accountType="org.sufficientlysecure.keychain.account"
|
android:accountType="@string/account_type"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name" />
|
android:label="@string/app_name" />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
|
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:contentAuthority="com.android.contacts"
|
android:contentAuthority="com.android.contacts"
|
||||||
android:accountType="org.sufficientlysecure.keychain.account"
|
android:accountType="@string/account_type"
|
||||||
android:supportsUploading="false"
|
android:supportsUploading="false"
|
||||||
android:userVisible="true"
|
android:userVisible="true"
|
||||||
android:allowParallelSyncs="false"
|
android:allowParallelSyncs="false"
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.sufficientlysecure.keychain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary workaround for https://github.com/robolectric/robolectric/issues/1747
|
||||||
|
*/
|
||||||
|
public final class WorkaroundBuildConfig {
|
||||||
|
public static final boolean DEBUG = BuildConfig.DEBUG;
|
||||||
|
// Workaround: Use real packageName not applicationId
|
||||||
|
public static final String APPLICATION_ID = "org.sufficientlysecure.keychain";
|
||||||
|
public static final String BUILD_TYPE = BuildConfig.BUILD_TYPE;
|
||||||
|
public static final String FLAVOR = BuildConfig.FLAVOR;
|
||||||
|
public static final int VERSION_CODE = BuildConfig.VERSION_CODE;
|
||||||
|
public static final String VERSION_NAME = BuildConfig.VERSION_NAME;
|
||||||
|
}
|
@ -22,11 +22,14 @@ import org.junit.Before;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
@ -51,9 +54,8 @@ import java.security.Security;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
|
||||||
public class CertifyOperationTest {
|
public class CertifyOperationTest {
|
||||||
|
|
||||||
static UncachedKeyRing mStaticRing1, mStaticRing2;
|
static UncachedKeyRing mStaticRing1, mStaticRing2;
|
||||||
@ -118,7 +120,7 @@ public class CertifyOperationTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
ProviderHelper providerHelper = new ProviderHelper(Robolectric.application);
|
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||||
|
|
||||||
// don't log verbosely here, we're not here to test imports
|
// don't log verbosely here, we're not here to test imports
|
||||||
ShadowLog.stream = oldShadowStream;
|
ShadowLog.stream = oldShadowStream;
|
||||||
@ -133,7 +135,7 @@ public class CertifyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSelfCertifyFlag() throws Exception {
|
public void testSelfCertifyFlag() throws Exception {
|
||||||
|
|
||||||
CanonicalizedPublicKeyRing ring = new ProviderHelper(Robolectric.application)
|
CanonicalizedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing1.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing1.getMasterKeyId());
|
||||||
Assert.assertEquals("secret key must be marked self-certified in database",
|
Assert.assertEquals("secret key must be marked self-certified in database",
|
||||||
// TODO this should be more correctly be VERIFIED_SELF at some point!
|
// TODO this should be more correctly be VERIFIED_SELF at some point!
|
||||||
@ -143,11 +145,11 @@ public class CertifyOperationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCertifyId() throws Exception {
|
public void testCertifyId() throws Exception {
|
||||||
CertifyOperation op = new CertifyOperation(Robolectric.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null, null);
|
new ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedPublicKeyRing ring = new ProviderHelper(Robolectric.application)
|
CanonicalizedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||||
Assert.assertEquals("public key must not be marked verified prior to certification",
|
Assert.assertEquals("public key must not be marked verified prior to certification",
|
||||||
Certs.UNVERIFIED, ring.getVerified());
|
Certs.UNVERIFIED, ring.getVerified());
|
||||||
@ -161,7 +163,7 @@ public class CertifyOperationTest {
|
|||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedPublicKeyRing ring = new ProviderHelper(Robolectric.application)
|
CanonicalizedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||||
Assert.assertEquals("new key must be verified now",
|
Assert.assertEquals("new key must be verified now",
|
||||||
Certs.VERIFIED_SECRET, ring.getVerified());
|
Certs.VERIFIED_SECRET, ring.getVerified());
|
||||||
@ -171,11 +173,11 @@ public class CertifyOperationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCertifyAttribute() throws Exception {
|
public void testCertifyAttribute() throws Exception {
|
||||||
CertifyOperation op = new CertifyOperation(Robolectric.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null, null);
|
new ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedPublicKeyRing ring = new ProviderHelper(Robolectric.application)
|
CanonicalizedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||||
Assert.assertEquals("public key must not be marked verified prior to certification",
|
Assert.assertEquals("public key must not be marked verified prior to certification",
|
||||||
Certs.UNVERIFIED, ring.getVerified());
|
Certs.UNVERIFIED, ring.getVerified());
|
||||||
@ -189,7 +191,7 @@ public class CertifyOperationTest {
|
|||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedPublicKeyRing ring = new ProviderHelper(Robolectric.application)
|
CanonicalizedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||||
Assert.assertEquals("new key must be verified now",
|
Assert.assertEquals("new key must be verified now",
|
||||||
Certs.VERIFIED_SECRET, ring.getVerified());
|
Certs.VERIFIED_SECRET, ring.getVerified());
|
||||||
@ -200,8 +202,8 @@ public class CertifyOperationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCertifySelf() throws Exception {
|
public void testCertifySelf() throws Exception {
|
||||||
CertifyOperation op = new CertifyOperation(Robolectric.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null, null);
|
new ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
||||||
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
||||||
@ -217,8 +219,8 @@ public class CertifyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCertifyNonexistent() throws Exception {
|
public void testCertifyNonexistent() throws Exception {
|
||||||
|
|
||||||
CertifyOperation op = new CertifyOperation(Robolectric.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null, null);
|
new ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
{
|
{
|
||||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
@ -23,10 +23,15 @@ import org.junit.BeforeClass;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
@ -48,8 +53,8 @@ import java.io.PrintStream;
|
|||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class ExportTest {
|
public class ExportTest {
|
||||||
|
|
||||||
static Passphrase mPassphrase = TestingUtils.genPassphrase(true);
|
static Passphrase mPassphrase = TestingUtils.genPassphrase(true);
|
||||||
@ -108,7 +113,7 @@ public class ExportTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
ProviderHelper providerHelper = new ProviderHelper(Robolectric.application);
|
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||||
|
|
||||||
// don't log verbosely here, we're not here to test imports
|
// don't log verbosely here, we're not here to test imports
|
||||||
ShadowLog.stream = oldShadowStream;
|
ShadowLog.stream = oldShadowStream;
|
||||||
@ -122,8 +127,8 @@ public class ExportTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExportAll() throws Exception {
|
public void testExportAll() throws Exception {
|
||||||
ImportExportOperation op = new ImportExportOperation(Robolectric.application,
|
ImportExportOperation op = new ImportExportOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
// make sure there is a local cert (so the later checks that there are none are meaningful)
|
// make sure there is a local cert (so the later checks that there are none are meaningful)
|
||||||
Assert.assertTrue("second keyring has local certification", checkForLocal(mStaticRing2));
|
Assert.assertTrue("second keyring has local certification", checkForLocal(mStaticRing2));
|
@ -23,11 +23,16 @@ import org.junit.BeforeClass;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
||||||
@ -50,8 +55,8 @@ import java.io.PrintStream;
|
|||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class PromoteKeyOperationTest {
|
public class PromoteKeyOperationTest {
|
||||||
|
|
||||||
static UncachedKeyRing mStaticRing;
|
static UncachedKeyRing mStaticRing;
|
||||||
@ -89,7 +94,7 @@ public class PromoteKeyOperationTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
ProviderHelper providerHelper = new ProviderHelper(Robolectric.application);
|
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||||
|
|
||||||
// don't log verbosely here, we're not here to test imports
|
// don't log verbosely here, we're not here to test imports
|
||||||
ShadowLog.stream = oldShadowStream;
|
ShadowLog.stream = oldShadowStream;
|
||||||
@ -102,15 +107,15 @@ public class PromoteKeyOperationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPromote() throws Exception {
|
public void testPromote() throws Exception {
|
||||||
PromoteKeyOperation op = new PromoteKeyOperation(Robolectric.application,
|
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null, null);
|
new ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
PromoteKeyResult result = op.execute(mStaticRing.getMasterKeyId(), null, null);
|
PromoteKeyResult result = op.execute(mStaticRing.getMasterKeyId(), null, null);
|
||||||
|
|
||||||
Assert.assertTrue("promotion must succeed", result.success());
|
Assert.assertTrue("promotion must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CachedPublicKeyRing ring = new ProviderHelper(Robolectric.application)
|
CachedPublicKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||||
.getCachedPublicKeyRing(mStaticRing.getMasterKeyId());
|
.getCachedPublicKeyRing(mStaticRing.getMasterKeyId());
|
||||||
Assert.assertTrue("key must have a secret now", ring.hasAnySecret());
|
Assert.assertTrue("key must have a secret now", ring.hasAnySecret());
|
||||||
|
|
||||||
@ -126,8 +131,8 @@ public class PromoteKeyOperationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPromoteDivert() throws Exception {
|
public void testPromoteDivert() throws Exception {
|
||||||
PromoteKeyOperation op = new PromoteKeyOperation(Robolectric.application,
|
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null, null);
|
new ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
||||||
|
|
||||||
@ -136,7 +141,7 @@ public class PromoteKeyOperationTest {
|
|||||||
Assert.assertTrue("promotion must succeed", result.success());
|
Assert.assertTrue("promotion must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedSecretKeyRing ring = new ProviderHelper(Robolectric.application)
|
CanonicalizedSecretKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||||
|
|
||||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
||||||
@ -151,8 +156,8 @@ public class PromoteKeyOperationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPromoteDivertSpecific() throws Exception {
|
public void testPromoteDivertSpecific() throws Exception {
|
||||||
PromoteKeyOperation op = new PromoteKeyOperation(Robolectric.application,
|
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null, null);
|
new ProviderHelper(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
||||||
|
|
||||||
@ -166,7 +171,7 @@ public class PromoteKeyOperationTest {
|
|||||||
Assert.assertTrue("promotion must succeed", result.success());
|
Assert.assertTrue("promotion must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedSecretKeyRing ring = new ProviderHelper(Robolectric.application)
|
CanonicalizedSecretKeyRing ring = new ProviderHelper(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||||
|
|
||||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
@ -20,10 +20,14 @@ package org.sufficientlysecure.keychain.pgp;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class KeyRingTest {
|
public class KeyRingTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -25,10 +25,13 @@ import org.junit.runner.RunWith;
|
|||||||
import org.openintents.openpgp.OpenPgpMetadata;
|
import org.openintents.openpgp.OpenPgpMetadata;
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.robolectric.*;
|
import org.robolectric.*;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
||||||
@ -52,8 +55,8 @@ import java.io.PrintStream;
|
|||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class PgpEncryptDecryptTest {
|
public class PgpEncryptDecryptTest {
|
||||||
|
|
||||||
static Passphrase mPassphrase = TestingUtils.genPassphrase(true);
|
static Passphrase mPassphrase = TestingUtils.genPassphrase(true);
|
||||||
@ -112,7 +115,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
ProviderHelper providerHelper = new ProviderHelper(Robolectric.application);
|
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||||
|
|
||||||
// don't log verbosely here, we're not here to test imports
|
// don't log verbosely here, we're not here to test imports
|
||||||
ShadowLog.stream = oldShadowStream;
|
ShadowLog.stream = oldShadowStream;
|
||||||
@ -134,8 +137,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(Robolectric.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@ -156,8 +159,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpDecryptVerify op = new PgpDecryptVerify(Robolectric.application,
|
PgpDecryptVerify op = new PgpDecryptVerify(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||||
input.setAllowSymmetricDecryption(true);
|
input.setAllowSymmetricDecryption(true);
|
||||||
DecryptVerifyResult result = op.execute(
|
DecryptVerifyResult result = op.execute(
|
||||||
@ -179,8 +182,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpDecryptVerify op = new PgpDecryptVerify(Robolectric.application,
|
PgpDecryptVerify op = new PgpDecryptVerify(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||||
input.setAllowSymmetricDecryption(true);
|
input.setAllowSymmetricDecryption(true);
|
||||||
DecryptVerifyResult result = op.execute(input,
|
DecryptVerifyResult result = op.execute(input,
|
||||||
@ -198,8 +201,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpDecryptVerify op = new PgpDecryptVerify(Robolectric.application,
|
PgpDecryptVerify op = new PgpDecryptVerify(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||||
input.setAllowSymmetricDecryption(true);
|
input.setAllowSymmetricDecryption(true);
|
||||||
DecryptVerifyResult result = op.execute(input,
|
DecryptVerifyResult result = op.execute(input,
|
||||||
@ -216,8 +219,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
ByteArrayInputStream in = new ByteArrayInputStream(ciphertext);
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpDecryptVerify op = new PgpDecryptVerify(Robolectric.application,
|
PgpDecryptVerify op = new PgpDecryptVerify(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||||
input.setAllowSymmetricDecryption(false);
|
input.setAllowSymmetricDecryption(false);
|
||||||
DecryptVerifyResult result = op.execute(input,
|
DecryptVerifyResult result = op.execute(input,
|
||||||
@ -240,8 +243,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(Robolectric.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel();
|
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel();
|
||||||
@ -321,8 +324,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(Robolectric.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@ -406,7 +409,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
||||||
|
|
||||||
// delete first key from database
|
// delete first key from database
|
||||||
new ProviderHelper(Robolectric.application).getContentResolver().delete(
|
new ProviderHelper(RuntimeEnvironment.application).getContentResolver().delete(
|
||||||
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -437,8 +440,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(Robolectric.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel();
|
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel();
|
||||||
@ -482,7 +485,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
||||||
|
|
||||||
// delete first key from database
|
// delete first key from database
|
||||||
new ProviderHelper(Robolectric.application).getContentResolver().delete(
|
new ProviderHelper(RuntimeEnvironment.application).getContentResolver().delete(
|
||||||
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -520,8 +523,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaindata);
|
ByteArrayInputStream in = new ByteArrayInputStream(plaindata);
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(Robolectric.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null);
|
new ProviderHelper(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel();
|
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel();
|
||||||
@ -562,8 +565,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
private PgpDecryptVerify operationWithFakePassphraseCache(
|
private PgpDecryptVerify operationWithFakePassphraseCache(
|
||||||
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
|
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
|
||||||
|
|
||||||
return new PgpDecryptVerify(Robolectric.application,
|
return new PgpDecryptVerify(RuntimeEnvironment.application,
|
||||||
new ProviderHelper(Robolectric.application), null) {
|
new ProviderHelper(RuntimeEnvironment.application), null) {
|
||||||
@Override
|
@Override
|
||||||
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
|
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
|
||||||
throws NoSecretKeyException {
|
throws NoSecretKeyException {
|
@ -26,6 +26,7 @@ import org.junit.Before;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.*;
|
import org.robolectric.*;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.BCPGInputStream;
|
import org.spongycastle.bcpg.BCPGInputStream;
|
||||||
import org.spongycastle.bcpg.Packet;
|
import org.spongycastle.bcpg.Packet;
|
||||||
@ -40,6 +41,8 @@ import org.spongycastle.bcpg.UserIDPacket;
|
|||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.spongycastle.openpgp.PGPSignature;
|
import org.spongycastle.openpgp.PGPSignature;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
@ -70,8 +73,8 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class PgpKeyOperationTest {
|
public class PgpKeyOperationTest {
|
||||||
|
|
||||||
static UncachedKeyRing staticRing;
|
static UncachedKeyRing staticRing;
|
@ -23,7 +23,9 @@ import org.junit.runner.RunWith;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.BCPGInputStream;
|
import org.spongycastle.bcpg.BCPGInputStream;
|
||||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||||
@ -51,7 +53,9 @@ import org.spongycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBu
|
|||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
|
||||||
import org.spongycastle.util.Strings;
|
import org.spongycastle.util.Strings;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
@ -78,8 +82,8 @@ import java.util.Iterator;
|
|||||||
* Test cases are made for all its assertions.
|
* Test cases are made for all its assertions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class UncachedKeyringCanonicalizeTest {
|
public class UncachedKeyringCanonicalizeTest {
|
||||||
|
|
||||||
static UncachedKeyRing staticRing;
|
static UncachedKeyRing staticRing;
|
@ -23,7 +23,9 @@ import org.junit.Before;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.BCPGInputStream;
|
import org.spongycastle.bcpg.BCPGInputStream;
|
||||||
import org.spongycastle.bcpg.PacketTags;
|
import org.spongycastle.bcpg.PacketTags;
|
||||||
@ -32,6 +34,8 @@ import org.spongycastle.bcpg.SecretKeyPacket;
|
|||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.spongycastle.util.Strings;
|
import org.spongycastle.util.Strings;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
@ -77,8 +81,8 @@ import java.util.Random;
|
|||||||
* packet will be copied regardless. Filtering out bad packets is done with canonicalization.
|
* packet will be copied regardless. Filtering out bad packets is done with canonicalization.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class UncachedKeyringMergeTest {
|
public class UncachedKeyringMergeTest {
|
||||||
|
|
||||||
static UncachedKeyRing staticRingA, staticRingB;
|
static UncachedKeyRing staticRingA, staticRingB;
|
@ -23,9 +23,13 @@ import org.junit.Before;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow;
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
@ -40,8 +44,8 @@ import java.io.IOException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class UncachedKeyringTest {
|
public class UncachedKeyringTest {
|
||||||
|
|
||||||
static UncachedKeyRing staticRing, staticPubRing;
|
static UncachedKeyRing staticRing, staticPubRing;
|
@ -26,22 +26,25 @@ import org.junit.Assert;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.*;
|
import org.robolectric.*;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.support.KeyringTestingHelper;
|
import org.sufficientlysecure.keychain.support.KeyringTestingHelper;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class ProviderHelperKeyringTest {
|
public class ProviderHelperKeyringTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSavePublicKeyring() throws Exception {
|
public void testSavePublicKeyring() throws Exception {
|
||||||
Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(Collections.singleton(
|
Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.application).addKeyring(Collections.singleton(
|
||||||
"/public-key-for-sample.blob"
|
"/public-key-for-sample.blob"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testSavePublicKeyringRsa() throws Exception {
|
public void testSavePublicKeyringRsa() throws Exception {
|
||||||
Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList(
|
Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.application).addKeyring(prependResourcePath(Arrays.asList(
|
||||||
"000001-006.public_key",
|
"000001-006.public_key",
|
||||||
"000002-013.user_id",
|
"000002-013.user_id",
|
||||||
"000003-002.sig",
|
"000003-002.sig",
|
||||||
@ -62,7 +65,7 @@ public class ProviderHelperKeyringTest {
|
|||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testSavePublicKeyringDsa() throws Exception {
|
public void testSavePublicKeyringDsa() throws Exception {
|
||||||
Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList(
|
Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.application).addKeyring(prependResourcePath(Arrays.asList(
|
||||||
"000016-006.public_key",
|
"000016-006.public_key",
|
||||||
"000017-002.sig",
|
"000017-002.sig",
|
||||||
"000018-012.ring_trust",
|
"000018-012.ring_trust",
|
||||||
@ -79,7 +82,7 @@ public class ProviderHelperKeyringTest {
|
|||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testSavePublicKeyringDsa2() throws Exception {
|
public void testSavePublicKeyringDsa2() throws Exception {
|
||||||
Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList(
|
Assert.assertTrue(new KeyringTestingHelper(RuntimeEnvironment.application).addKeyring(prependResourcePath(Arrays.asList(
|
||||||
"000027-006.public_key",
|
"000027-006.public_key",
|
||||||
"000028-002.sig",
|
"000028-002.sig",
|
||||||
"000029-012.ring_trust",
|
"000029-012.ring_trust",
|
@ -23,10 +23,15 @@ import org.junit.BeforeClass;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||||
@ -40,11 +45,11 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class ProviderHelperSaveTest {
|
public class ProviderHelperSaveTest {
|
||||||
|
|
||||||
ProviderHelper mProviderHelper = new ProviderHelper(Robolectric.application);
|
ProviderHelper mProviderHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpOnce() throws Exception {
|
public static void setUpOnce() throws Exception {
|
||||||
@ -62,17 +67,17 @@ public class ProviderHelperSaveTest {
|
|||||||
SaveKeyringResult result;
|
SaveKeyringResult result;
|
||||||
|
|
||||||
// insert both keys, second should fail
|
// insert both keys, second should fail
|
||||||
result = new ProviderHelper(Robolectric.application).savePublicKeyRing(first);
|
result = new ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||||
result = new ProviderHelper(Robolectric.application).savePublicKeyRing(second);
|
result = new ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||||
Assert.assertFalse("second keyring import should fail", result.success());
|
Assert.assertFalse("second keyring import should fail", result.success());
|
||||||
|
|
||||||
new KeychainDatabase(Robolectric.application).clearDatabase();
|
new KeychainDatabase(RuntimeEnvironment.application).clearDatabase();
|
||||||
|
|
||||||
// and the other way around
|
// and the other way around
|
||||||
result = new ProviderHelper(Robolectric.application).savePublicKeyRing(second);
|
result = new ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||||
result = new ProviderHelper(Robolectric.application).savePublicKeyRing(first);
|
result = new ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||||
Assert.assertFalse("second keyring import should fail", result.success());
|
Assert.assertFalse("second keyring import should fail", result.success());
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -91,13 +96,13 @@ public class ProviderHelperSaveTest {
|
|||||||
SaveKeyringResult result;
|
SaveKeyringResult result;
|
||||||
|
|
||||||
// insert secret, this should fail because of missing self-cert
|
// insert secret, this should fail because of missing self-cert
|
||||||
result = new ProviderHelper(Robolectric.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
result = new ProviderHelper(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||||
Assert.assertFalse("secret keyring import before pubring import should fail", result.success());
|
Assert.assertFalse("secret keyring import before pubring import should fail", result.success());
|
||||||
|
|
||||||
// insert pubkey, then seckey - both should succeed
|
// insert pubkey, then seckey - both should succeed
|
||||||
result = new ProviderHelper(Robolectric.application).savePublicKeyRing(pubkey);
|
result = new ProviderHelper(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||||
Assert.assertTrue("public keyring import should succeed", result.success());
|
Assert.assertTrue("public keyring import should succeed", result.success());
|
||||||
result = new ProviderHelper(Robolectric.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
result = new ProviderHelper(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||||
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
|
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
|
||||||
|
|
||||||
}
|
}
|
@ -19,13 +19,17 @@ import org.junit.Assert;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.util.Iso7816TLV.Iso7816CompositeTLV;
|
import org.sufficientlysecure.keychain.util.Iso7816TLV.Iso7816CompositeTLV;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class Iso7816TLVTest {
|
public class Iso7816TLVTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
@ -25,16 +25,21 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowLog;
|
import org.robolectric.shadows.ShadowLog;
|
||||||
|
import org.sufficientlysecure.keychain.BuildConfig;
|
||||||
|
import org.sufficientlysecure.keychain.WorkaroundBuildConfig;
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableFileCache.IteratorWithSize;
|
import org.sufficientlysecure.keychain.util.ParcelableFileCache.IteratorWithSize;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@Config(constants = WorkaroundBuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml")
|
||||||
public class ParcelableFileCacheTest {
|
public class ParcelableFileCacheTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -45,7 +50,7 @@ public class ParcelableFileCacheTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testInputOutput() throws Exception {
|
public void testInputOutput() throws Exception {
|
||||||
|
|
||||||
ParcelableFileCache<Bundle> cache = new ParcelableFileCache<Bundle>(Robolectric.application, "test.pcl");
|
ParcelableFileCache<Bundle> cache = new ParcelableFileCache<Bundle>(RuntimeEnvironment.application, "test.pcl");
|
||||||
|
|
||||||
ArrayList<Bundle> list = new ArrayList<Bundle>();
|
ArrayList<Bundle> list = new ArrayList<Bundle>();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user