-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from mysteriumnetwork/payments-integration
Add initial payments integration
- Loading branch information
Showing
52 changed files
with
1,893 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
android/app/build/ | ||
android/build | ||
android/lint | ||
android/app/lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ build/ | |
local.properties | ||
*.iml | ||
ios/Index/ | ||
android/app/lint | ||
android/lint | ||
|
||
# test | ||
.jest/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,72 @@ | ||
image: mysteriumnetwork/mobile-ci:0.1.0 | ||
|
||
stages: | ||
- deploy | ||
- environment | ||
- build | ||
- test | ||
- internal | ||
|
||
push-beta: | ||
stage: deploy | ||
when: manual | ||
.updateContainerJob: | ||
image: docker:stable | ||
stage: environment | ||
services: | ||
- docker:dind | ||
script: | ||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | ||
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG || true | ||
- docker build --cache-from $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG . | ||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG | ||
|
||
updateContainer: | ||
extends: .updateContainerJob | ||
only: | ||
- master | ||
- /^release-*/ | ||
changes: | ||
- Dockerfile | ||
|
||
ensureContainer: | ||
extends: .updateContainerJob | ||
allow_failure: true | ||
before_script: | ||
- "mkdir -p ~/.docker && echo '{\"experimental\": \"enabled\"}' > ~/.docker/config.json" | ||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | ||
# Skip update container `script` if the container already exists | ||
# via https://gitlab.com/gitlab-org/gitlab-ce/issues/26866#note_97609397 -> https://stackoverflow.com/a/52077071/796832 | ||
- docker manifest inspect $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG > /dev/null && exit || true | ||
|
||
.build_job: | ||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG | ||
stage: build | ||
before_script: | ||
- "export VERSION_CODE=$((100 + $CI_PIPELINE_IID)) && echo $VERSION_CODE" | ||
- "export VERSION_SHA=`echo ${CI_COMMIT_SHA:0:8}` && echo $VERSION_SHA" | ||
# Because we allow the MR creation to fail, just make sure we are back in the right repo state | ||
- git checkout "$CI_COMMIT_SHA" | ||
after_script: | ||
- rm -f android-signing-keystore.jks || true | ||
artifacts: | ||
paths: | ||
- app/build/outputs | ||
|
||
buildDebug: | ||
extends: .build_job | ||
script: | ||
- bundle exec fastlane buildDebug | ||
|
||
testDebug: | ||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG | ||
stage: test | ||
dependencies: | ||
- buildDebug | ||
script: | ||
- bundle exec fastlane test | ||
|
||
publishInternal: | ||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG | ||
stage: internal | ||
when: manual | ||
before_script: | ||
- echo "$FASTLANE_ANDROID_SIGNING_FILE_VALUE" | base64 --decode > "$FASTLANE_ANDROID_SIGNING_FILE_PATH" | ||
- echo "$FASTLANE_ANDROID_SECRET_JSON_VALUE" | base64 --decode > "$FASTLANE_ANDROID_SECRET_JSON_PATH" | ||
- echo "$GOOGLE_SERVICES_VALUE" | base64 --decode > "$GOOGLE_SERVICES_PATH" | ||
- bundle update --bundler | ||
- fastlane android beta | ||
after_script: | ||
- rm -f $GOOGLE_SERVICES_PATH $FASTLANE_ANDROID_SIGNING_FILE_PATH $FASTLANE_ANDROID_SECRET_JSON_PATH | ||
script: | ||
- bundle exec fastlane internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM openjdk:8-jdk | ||
|
||
# Just matched `app/build.gradle` | ||
ENV ANDROID_COMPILE_SDK "28" | ||
# Just matched `app/build.gradle` | ||
ENV ANDROID_BUILD_TOOLS "28.0.3" | ||
# Version from https://developer.android.com/studio/releases/sdk-tools | ||
ENV ANDROID_SDK_TOOLS "4333796" | ||
|
||
ENV ANDROID_HOME /android-sdk-linux | ||
ENV PATH="${PATH}:/android-sdk-linux/platform-tools/" | ||
|
||
# Install OS packages | ||
RUN apt-get --quiet update --yes | ||
RUN apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 build-essential ruby ruby-dev | ||
# We use this for xxd hex->binary | ||
RUN apt-get --quiet install --yes vim-common | ||
# Install Android SDK | ||
RUN wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip | ||
RUN unzip -q android-sdk.zip -d "$ANDROID_HOME/" | ||
# Accept Android SDK licenses | ||
RUN yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses | ||
|
||
RUN echo y | android-sdk-linux/tools/android update sdk --no-ui --all --filter android-${ANDROID_COMPILE_SDK} | ||
RUN echo y | android-sdk-linux/tools/android update sdk --no-ui --all --filter platform-tools | ||
RUN echo y | android-sdk-linux/tools/android update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS} | ||
RUN echo y | android-sdk-linux/tools/android update sdk --no-ui --all --filter extra-android-m2repository | ||
RUN echo y | android-sdk-linux/tools/android update sdk --no-ui --all --filter extra-google-google_play_services | ||
RUN echo y | android-sdk-linux/tools/android update sdk --no-ui --all --filter extra-google-m2repository | ||
# install Fastlane | ||
COPY Gemfile.lock . | ||
COPY Gemfile . | ||
RUN gem install bundle | ||
RUN bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
android/app/src/androidTest/java/network/mysterium/BasicFlowTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package network.mysterium | ||
|
||
import androidx.test.espresso.action.ViewActions.* | ||
import androidx.test.filters.LargeTest | ||
import androidx.test.rule.ActivityTestRule | ||
import androidx.test.runner.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@LargeTest | ||
@RunWith(AndroidJUnit4::class) | ||
class BasicFlowTest { | ||
|
||
@Rule | ||
@JvmField | ||
var mActivityTestRule = ActivityTestRule(MainActivity::class.java) | ||
|
||
@Test | ||
fun registeredIdentityFlowTest() { | ||
Views.checkStatusLabel("Disconnected") | ||
Views.selectProposalLayout.perform(click()) | ||
|
||
Views.proposalSearchInput.perform(replaceText("0xfbf"), closeSoftKeyboard()) | ||
|
||
Views.selectProposalItem(0) | ||
|
||
Views.connectionButton.perform(click()) | ||
|
||
Views.checkStatusLabel("Connected") | ||
|
||
Thread.sleep(5000) | ||
|
||
Views.connectionButton.perform(click()) | ||
|
||
Views.checkStatusLabel("Disconnected") | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
android/app/src/androidTest/java/network/mysterium/BasicFlowWithRegistrationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package network.mysterium | ||
|
||
import androidx.test.espresso.action.ViewActions.* | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import androidx.test.filters.LargeTest | ||
import androidx.test.rule.ActivityTestRule | ||
import androidx.test.runner.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@LargeTest | ||
@RunWith(AndroidJUnit4::class) | ||
class BasicFlowWithRegistrationTest { | ||
|
||
@Rule | ||
@JvmField | ||
var mActivityTestRule = ActivityTestRule(MainActivity::class.java) | ||
|
||
// TODO: For some reasons this fails with Failed to grant permissions, see logcat for details error. | ||
// @Rule | ||
// @JvmField | ||
// val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(android.Manifest.permission.BIND_VPN_SERVICE) | ||
|
||
@Test | ||
fun basicFlowWithRegistrationTest() { | ||
Views.acceptTermsButton.perform(click()) | ||
|
||
Views.balanceLabel.perform(click()) | ||
|
||
Views.registrationPleaseWaitLabel.check(matches(withText("Please wait"))) | ||
|
||
Views.topUpButton.check(matches(isDisplayed())) | ||
|
||
Views.navBackButton.perform(click()) | ||
|
||
Views.selectProposalLayout.perform(click()) | ||
|
||
Views.proposalSearchInput.perform(replaceText("0xfbf"), closeSoftKeyboard()) | ||
|
||
Views.selectProposalItem(0) | ||
|
||
Views.connectionButton.perform(click()) | ||
|
||
Views.checkStatusLabel("Connected") | ||
|
||
Views.connectionButton.perform(click()) | ||
|
||
Views.checkStatusLabel("Disconnected") | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
android/app/src/androidTest/java/network/mysterium/Helpers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package network.mysterium | ||
|
||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.NoMatchingViewException | ||
import androidx.test.espresso.ViewInteraction | ||
import androidx.test.espresso.assertion.ViewAssertions | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import org.hamcrest.Description | ||
import org.hamcrest.Matcher | ||
import org.hamcrest.TypeSafeMatcher | ||
|
||
fun onViewReady(viewMatcher: Matcher<View>, count: Int = 3, sleepMillis: Long = 2000): ViewInteraction { | ||
for (i in 1..count) { | ||
try { | ||
return Espresso.onView(viewMatcher).check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | ||
} catch (e: NoMatchingViewException) { | ||
if (i == count) { | ||
throw e | ||
} | ||
Thread.sleep(sleepMillis) | ||
} | ||
} | ||
throw Throwable("view not found") | ||
} | ||
|
||
fun childAtPosition( | ||
parentMatcher: Matcher<View>, position: Int): Matcher<View> { | ||
|
||
return object : TypeSafeMatcher<View>() { | ||
override fun describeTo(description: Description) { | ||
description.appendText("Child at position $position in parent ") | ||
parentMatcher.describeTo(description) | ||
} | ||
|
||
public override fun matchesSafely(view: View): Boolean { | ||
val parent = view.parent | ||
return parent is ViewGroup && parentMatcher.matches(parent) | ||
&& view == parent.getChildAt(position) | ||
} | ||
} | ||
} |
Oops, something went wrong.