-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detox #26
Detox #26
Changes from all commits
5156b03
a135e8b
bedf211
b2397e6
b280036
487a645
7a94375
2bd464c
bf9f553
500470d
03f3358
0cdca4e
91508b8
39919c7
d0402c0
81aed5b
4662b2a
cbc5eec
4b36be1
905433d
de6824a
4540918
8f4d1c1
6242961
a8cf21e
48f5e12
8b5a969
c065df6
c235dde
0685882
bbdbbe0
467a591
50d9900
e6b52ad
2f6a75c
a6a32af
dff781d
a565988
b563268
9a8f407
3cbb5a5
0314527
1855763
a92fd4d
39eb25d
bbf6367
51c3f3c
becab52
3defe29
4abbd18
2d12a1a
7badc02
d1f6e48
3ae77a5
7a48c46
6830337
772c395
69460ca
aa1d73c
c762ff9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- "8" | ||
- '8' | ||
branches: | ||
only: | ||
- master | ||
- master |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { Component } from 'react'; | ||
import { encryptWithAes } from '../src/utils/meat-grinder.js'; | ||
import { View, Text } from 'react-native'; | ||
var inputSizes = [16, 20, 48]; | ||
const testPrivateKey = | ||
'8238BAE35C77FE4AEBB2DEB1B83A6F0027A01D0E4D93BF5B81F7117796955A17'; | ||
export default class E2ETests extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { input16: 0, input20: 0, input48: 0 }; | ||
inputSizes.map(inputSize => { | ||
this.encryptForSize(inputSize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best to do this on componentDidMount() for initialization There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. next PR |
||
}); | ||
} | ||
async encryptForSize(sizeInBytes) { | ||
let aesOutput = await encryptWithAes( | ||
testPrivateKey, | ||
new Array(sizeInBytes).join('x') | ||
); | ||
if (!aesOutput) { | ||
throw Error('output is not good'); | ||
} | ||
this.setState({ ['input'.concat(sizeInBytes)]: aesOutput.ciphertext }); | ||
return 'success'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return seems unnecessary ? |
||
} | ||
render() { | ||
return ( | ||
<View testID="welcome" style={{ flex: 1, justifyContent: 'center' }}> | ||
<Text testID="16ByteInput">{this.state.input16.length}</Text> | ||
<Text testID="20ByteInput">{this.state.input20.length}</Text> | ||
<Text testID="48ByteInput">{this.state.input48.length}</Text> | ||
</View> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
barlock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"setupTestFrameworkScriptFile": "./init.js", | ||
"testEnvironment": "node" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-env detox/detox, jest*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in the .eslint file so you don't need it 🎉 |
||
describe('Example', () => { | ||
beforeEach(async () => { | ||
await device.reloadReactNative(); | ||
}); | ||
|
||
it('should have welcome screen', async () => { | ||
await expect(element(by.id('16ByteInput'))).toHaveText('24'); | ||
}); | ||
/* it('should show hello screen after tap', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for commented code? Looks like boiler plate you didn't delete? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. placeholder -- will be deleted in next pull request |
||
await element(by.id('hello_button')).tap(); | ||
await expect(element(by.text('Hello!!!'))).toBeVisible(); | ||
}); | ||
|
||
it('should show world screen after tap', async () => { | ||
await element(by.id('world_button')).tap(); | ||
await expect(element(by.text('World!!!'))).toBeVisible(); | ||
}); | ||
*/ | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const detox = require('detox'); | ||
const config = require('../package.json').detox; | ||
const adapter = require('detox/runners/jest/adapter'); | ||
const { exec } = require('child_process'); | ||
|
||
jest.setTimeout(120000); | ||
jasmine.getEnv().addReporter(adapter); | ||
hadasz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
beforeAll(async () => { | ||
exec('cp index.e2e.js index.js'); | ||
await detox.init(config); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await adapter.beforeEach(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await adapter.afterAll(); | ||
exec('rm index.js'); | ||
await detox.cleanup(); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { AppRegistry } from 'react-native'; | ||
import { name as appName } from './app.json'; | ||
import E2ETests from './e2e/E2ETests'; | ||
AppRegistry.registerComponent(appName, () => E2ETests); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { AppRegistry } from 'react-native'; | ||
import App from './src/App'; | ||
import { name as appName } from './app.json'; | ||
AppRegistry.registerComponent(appName, () => App); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Aes from 'react-native-aes-crypto'; | ||
//arguments: file - plaintext file | ||
//return value:encrypted file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 Nice! I love the documentation. Is this format a standard? Should we use JSDoc instead? I see that fairly commonly. |
||
export async function encryptWithAes(privateKey, plainTextFile) { | ||
const iv = 'sixteen bytes iv'; //To DO: randomly generate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did you plan on using an IV? Per file/user? I think they're optional, though definitely good practice, yeah? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IV will be used per file, so nobody can do cryptanalysis on it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have any thoughts on how we're going to store the IV? I'm guessing it will need to go in the azure "how to decrypt" file? (Obviously not necessary for this pr, just curious) |
||
try { | ||
const ciphertext = await Aes.encrypt(plainTextFile, privateKey, iv); | ||
return { ciphertext, iv }; | ||
} catch (error) { | ||
throw error; | ||
} | ||
} | ||
|
||
//arguments: encrypted file | ||
//return value: array of (x,y) coordinates | ||
/* | ||
|
||
|
||
|
||
import Aes from '@trackforce/react-native-aes-crypto'; | ||
|
||
//arguments: file - plaintext file | ||
//return value:encrypted file | ||
export async function encryptWithAes(privateKey, plainTextFile) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's all of the commented code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that was for mocking purposes for John, Will be filled in as I complete it |
||
const iv = 'sixteen bytes iv'; //To DO: randomly generate | ||
try { | ||
const ciphertext = await Aes.encrypt(plainTextFile, privateKey, iv); | ||
return { ciphertext, iv }; | ||
} catch (error) { | ||
throw error; | ||
} | ||
} | ||
|
||
//arguments: encrypted file | ||
//return value: array of (x,y) coordinates | ||
function encryptWithShamirs(encryptedFile) {} | ||
//arguments:array points needed to reconstruct encryptedFile | ||
//return value: array of new (x,y) coordinates | ||
function hashPointsWithPrivateKey(arrayOfPoints) {} | ||
//argument: array of (x,y) coordinates | ||
//return value: Promise that resolves to an array of IPFS Hashe's | ||
async function submitPointsToIPFS(points) {} | ||
|
||
async function saveToVault(plainTextFile) { | ||
let points = hashPointsWithPrivateKey( | ||
encryptWithShamirs(encryptWithAes(plainTextFile)) | ||
); | ||
let ipfsHashes = await submitPointsToIPFS(points); | ||
return ipfsHashes; | ||
} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructors can't be async so doing async here means you have uncaught exceptions.
The right place is
compomnentDidMount
☝️ Class properties mean less typing!