-
Notifications
You must be signed in to change notification settings - Fork 4
add unit testing fix some bugs #4
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
base: master
Are you sure you want to change the base?
Changes from all commits
1dbca17
0fc70e5
8ee6040
babd232
03a0c15
6d27628
5310c40
f345bee
1e6244f
55e794f
faaf57d
9b20f81
ba81b74
af0f307
6f4837d
0af0489
ffd8821
afe7c9f
a9a2654
fe74ef2
e8a8388
3824bae
1138551
bd5edbc
a645dee
b9b071f
00c74b4
7502bed
edafd33
fd481c3
96cda34
a8e7adc
5532e4e
45249e5
9725b7e
2d13787
f7339dd
a342f7e
f83016e
789f097
bb07200
2812bab
e66482b
4bb0e45
2471ebd
e6ce6b3
1689b45
f1fb12a
72a8601
2992749
3c0156d
24b7c58
6497c39
34be77a
750f7c8
504b974
1ad2054
be2bd28
ee092c0
8980b4b
3b23b04
bbae44c
fab6203
83c3a28
a62af70
72d5476
c6308a9
a9b1719
c3096f6
2c15dc1
e2a5f32
280b289
60a7046
e9266ec
7c5c0d6
a6ea9e5
5813b3d
c5e76b9
1f85d38
2fa9cb2
99a98d5
cc3884b
97ac8f0
ae358c6
bee3ed6
93efbe3
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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
|
|
||
| [composer.json] | ||
| indent_style = space | ||
| indent_size = 4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| language: php | ||
|
|
||
| php: | ||
| - 5.6 | ||
| - 7.0 | ||
| - nightly | ||
|
|
||
| sudo: false | ||
|
|
||
| env: | ||
| global: | ||
| - PATH="$HOME/.composer/vendor/bin:$PATH" | ||
|
|
||
| cache: | ||
| directories: | ||
| - $HOME/.composer/cache | ||
|
|
||
| matrix: | ||
| fast_finish: true | ||
| include: | ||
| - php: 5.6 | ||
| env: COMPOSER_FLAGS="--prefer-lowest" | ||
| allow_failures: | ||
| - php: nightly | ||
|
|
||
| before_install: | ||
| - phpenv global 5.6 | ||
|
|
||
| install: | ||
| - mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d && echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
| - mkdir -p build/logs | ||
| - composer global require satooshi/php-coveralls:@stable --no-update | ||
| - composer global update --prefer-dist --no-interaction | ||
| - composer update --prefer-dist --no-interaction $COMPOSER_FLAGS | ||
|
|
||
| before_script: | ||
| - composer require phpunit/phpunit | ||
| - travis_wait php generate_fake.php 0 | ||
| - travis_wait php generate_fake.php 1 | ||
|
Contributor
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.
|
||
| - travis_wait php generate_fake.php 2 | ||
| - travis_wait php generate_fake.php 3 | ||
|
|
||
| script: | ||
| - vendor/bin/phpunit | ||
|
Contributor
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. Use global PHPUnit instead. |
||
|
|
||
| after_script: | ||
| - coveralls -v | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| <?php | ||
|
|
||
| // generate the fake .well-known folder and upload the folder to the testing web hosting. | ||
|
Contributor
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. Generates |
||
|
|
||
| use Nexy\NexyCrypt\Authorization\Challenge\Http01Challenge; | ||
| use Nexy\NexyCrypt\Exception\AcmeApiException; | ||
| use Nexy\NexyCrypt\NexyCrypt; | ||
|
|
||
| require_once __DIR__.'/vendor/autoload.php'; | ||
|
|
||
| if ($argc > 2) { | ||
| echo 'You have to pass too many arguments.'.PHP_EOL; | ||
|
Contributor
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 do you mean? This sentence is not understandable.
Author
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. Yeah, you're right . This syntax is not readable so I use |
||
| exit(1); | ||
| } | ||
|
|
||
| if(isset($argv[1])) { | ||
| $step = intval($argv[1]); | ||
| } else { | ||
| echo 'You have to pass the step arguments.'.PHP_EOL; | ||
| exit(1); | ||
| } | ||
|
|
||
| $accounts = json_decode(file_get_contents('tests/ftpserver.json'), true); | ||
| $domain = $accounts['ftpserver']; | ||
|
|
||
| // First commented line is for production. | ||
| //$client = new NexyCrypt(); | ||
|
Contributor
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. Commented code should not be here. Plus, I don't think this should be used for production. |
||
| $client = new NexyCrypt(null, 'https://acme-staging.api.letsencrypt.org/'); | ||
|
|
||
| try { | ||
| if (0 === $step) { | ||
| // create the required account private key | ||
| $client->create(); | ||
| } | ||
|
|
||
| if (1 === $step) { | ||
| $client->register(); | ||
| $client->agreeTerms(); | ||
| } | ||
|
|
||
| if (2 === $step) { | ||
| $client->register(); | ||
| $client->agreeTerms(); | ||
|
|
||
| @mkdir('tests/public'); | ||
|
|
||
| $authorization = $client->authorize($domain); | ||
|
|
||
| $challenge = $authorization->getChallenges()->getHttp01(); | ||
|
|
||
| @mkdir('tests/public/acme-challenge'); | ||
| file_put_contents('tests/public/'.'acme-challenge'.'/'.$challenge->getFileName(), $challenge->getFileContent()); | ||
| file_put_contents('tests/public/'.'acme-challenge'.'/challenge', serialize($challenge)); | ||
| } | ||
|
|
||
| if (3 === $step) { | ||
| // upload file to the remote server | ||
| $accounts = json_decode(file_get_contents('tests/ftpserver.json'), true); | ||
| $user = $accounts['username']; | ||
|
|
||
| // the ftp server password is temporarily created and DO NOT use this value to do other things. | ||
| // the free web hosting will be closed or reset at the irregular time. | ||
| $password = $accounts['password']; | ||
| $ftpServer = $accounts['ftpserver']; | ||
|
|
||
| // set up basic ftp connection | ||
| $connectId = ftp_connect($ftpServer); | ||
|
|
||
| // login with username and password | ||
| $loginResult = ftp_login($connectId, $user, $password); | ||
|
|
||
| ftp_pasv($connectId, true); | ||
|
|
||
| if (!$loginResult) { | ||
| // PHP will already have raised an E_WARNING level message in this case | ||
| echo "can't login"; | ||
| exit(1); | ||
| } | ||
|
|
||
| @ftp_mkdir($connectId, '.well-known'); | ||
| @ftp_mkdir($connectId, '.well-known/acme-challenge'); | ||
|
|
||
| ftp_chdir($connectId, '.well-known/acme-challenge'); | ||
|
|
||
| // upload the files from the folders | ||
| $filePath = 'tests/public/acme-challenge'; | ||
| $filesArr = scandir($filePath); | ||
| $fileCount = count($filesArr); | ||
| for($index=2;$index<$fileCount;$index++) { | ||
| $result = ftp_put($connectId, $filesArr[$index], $filePath.'/'.$filesArr[$index], FTP_ASCII); | ||
| if ($result === false) { | ||
| echo 'cannot upload file: '.$filesArr[$index]; | ||
| exit(1); | ||
| } | ||
| } | ||
|
|
||
| ftp_close($connectId); | ||
| } | ||
|
|
||
| exit(0); | ||
| } catch (AcmeApiException $e) { | ||
| var_dump($e->getDetails()); | ||
|
|
||
| exit(1); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <phpunit | ||
| colors="true" | ||
| bootstrap="./vendor/autoload.php" | ||
| charset="UTF-8"> | ||
|
|
||
| <testsuites> | ||
| <testsuite name="Testing Suite"> | ||
| <directory suffix=".php">./tests/</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
|
|
||
| <filter> | ||
| <whitelist> | ||
| <directory>./src/</directory> | ||
| </whitelist> | ||
| </filter> | ||
|
|
||
| <logging> | ||
| <log type="coverage-clover" target="build/logs/clover.xml"/> | ||
| <log type="coverage-html" target="result/" /> | ||
| </logging> | ||
|
|
||
| </phpunit> |
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.
What is the goal of this?