Merge pull request #1419 from larshp/issue_1418

docs: update SSL test program
This commit is contained in:
Lars Hvam 2018-05-29 15:56:43 +02:00 committed by GitHub
commit 4974e0c8d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 15 deletions

View File

@ -11,21 +11,34 @@ REPORT zabapgit_test_ssl.
* See https://github.com/larshp/abapGit/
PARAMETERS: p_url TYPE swc_value DEFAULT 'https://github.com',
p_proxy TYPE string,
p_pxport TYPE string.
PARAMETERS: p_url1 TYPE swc_value DEFAULT 'https://github.com',
p_url2 TYPE swc_value DEFAULT 'https://api.github.com'.
* api.github.com is used when pushing code back to github
SELECTION-SCREEN BEGIN OF BLOCK proxy WITH FRAME.
* proxy settings, fill if your system is behind a proxy
PARAMETERS: p_proxy TYPE string,
p_pxport TYPE string,
p_puser TYPE string,
p_ppwd TYPE string.
SELECTION-SCREEN END OF BLOCK proxy.
START-OF-SELECTION.
PERFORM run.
PERFORM run USING p_url1.
PERFORM run USING p_url2.
FORM run.
FORM run USING iv_url TYPE swc_value.
DATA: lv_code TYPE i,
lv_url TYPE string,
li_client TYPE REF TO if_http_client,
lv_error_message TYPE string.
lv_url = p_url.
IF iv_url IS INITIAL.
RETURN.
ENDIF.
lv_url = iv_url.
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
@ -35,11 +48,12 @@ FORM run.
IMPORTING
client = li_client ).
* enter username and password for proxy authentication if needed
* li_client->authenticate(
* proxy_authentication = abap_true
* username = ''
* password = '' ).
IF NOT p_puser IS INITIAL.
li_client->authenticate(
proxy_authentication = abap_true
username = p_puser
password = p_ppwd ).
ENDIF.
li_client->send( ).
li_client->receive(
@ -65,7 +79,7 @@ FORM run.
IMPORTING
code = lv_code ).
IF lv_code = 200.
WRITE: / 'Success, it works'.
WRITE: / lv_url, ': ok'.
ELSE.
WRITE: / 'Error', lv_code.
ENDIF.

View File

@ -60,7 +60,7 @@ ENDCLASS.
CLASS zcl_abapgit_2fa_github_auth IMPLEMENTATION.
CLASS ZCL_ABAPGIT_2FA_GITHUB_AUTH IMPLEMENTATION.
METHOD constructor.
@ -336,6 +336,8 @@ CLASS zcl_abapgit_2fa_github_auth IMPLEMENTATION.
li_client->receive( EXCEPTIONS OTHERS = 1 ).
IF sy-subrc <> 0.
* if the code fails here with a SSL error, make sure STRUST is setup to
* work with https://api.github.com
raise_comm_error_from_sy( ).
ENDIF.