mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 04:08:27 +08:00
decouple http from login manager (#6108)
This commit is contained in:
parent
4a68f896b1
commit
323b345d03
|
@ -48,7 +48,7 @@ ENDCLASS.
|
|||
|
||||
|
||||
|
||||
CLASS zcl_abapgit_http IMPLEMENTATION.
|
||||
CLASS ZCL_ABAPGIT_HTTP IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD acquire_login_details.
|
||||
|
@ -119,6 +119,7 @@ CLASS zcl_abapgit_http IMPLEMENTATION.
|
|||
|
||||
DATA: lv_uri TYPE string,
|
||||
lv_scheme TYPE string,
|
||||
lv_authorization TYPE string,
|
||||
li_client TYPE REF TO if_http_client,
|
||||
lo_proxy_configuration TYPE REF TO zcl_abapgit_proxy_config,
|
||||
lv_text TYPE string.
|
||||
|
@ -188,9 +189,13 @@ CLASS zcl_abapgit_http IMPLEMENTATION.
|
|||
" Disable internal auth dialog (due to its unclarity)
|
||||
li_client->propertytype_logon_popup = if_http_client=>co_disabled.
|
||||
|
||||
zcl_abapgit_login_manager=>load(
|
||||
iv_uri = iv_url
|
||||
ii_client = li_client ).
|
||||
lv_authorization = zcl_abapgit_login_manager=>load( iv_url ).
|
||||
IF lv_authorization IS NOT INITIAL.
|
||||
li_client->request->set_header_field(
|
||||
name = 'authorization'
|
||||
value = lv_authorization ).
|
||||
li_client->propertytype_logon_popup = li_client->co_disabled.
|
||||
ENDIF.
|
||||
|
||||
zcl_abapgit_exit=>get_instance( )->http_client(
|
||||
iv_url = iv_url
|
||||
|
@ -206,8 +211,9 @@ CLASS zcl_abapgit_http IMPLEMENTATION.
|
|||
ro_client->check_http_200( ).
|
||||
|
||||
IF lv_scheme <> c_scheme-digest.
|
||||
zcl_abapgit_login_manager=>save( iv_uri = iv_url
|
||||
ii_client = li_client ).
|
||||
zcl_abapgit_login_manager=>save(
|
||||
iv_uri = iv_url
|
||||
iv_authorization = li_client->request->get_header_field( 'authorization' ) ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
|
|
@ -8,15 +8,14 @@ CLASS zcl_abapgit_login_manager DEFINITION
|
|||
CLASS-METHODS load
|
||||
IMPORTING
|
||||
!iv_uri TYPE string
|
||||
!ii_client TYPE REF TO if_http_client OPTIONAL
|
||||
RETURNING
|
||||
VALUE(rv_authorization) TYPE string
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS save
|
||||
IMPORTING
|
||||
!iv_uri TYPE string
|
||||
!ii_client TYPE REF TO if_http_client
|
||||
!iv_uri TYPE string
|
||||
!iv_authorization TYPE string
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS clear .
|
||||
|
@ -97,18 +96,11 @@ CLASS ZCL_ABAPGIT_LOGIN_MANAGER IMPLEMENTATION.
|
|||
|
||||
METHOD load.
|
||||
|
||||
DATA: ls_auth LIKE LINE OF gt_auth.
|
||||
DATA ls_auth LIKE LINE OF gt_auth.
|
||||
|
||||
READ TABLE gt_auth INTO ls_auth WITH KEY uri = zcl_abapgit_url=>host( iv_uri ).
|
||||
IF sy-subrc = 0.
|
||||
rv_authorization = ls_auth-authorization.
|
||||
|
||||
IF NOT ii_client IS INITIAL.
|
||||
ii_client->request->set_header_field(
|
||||
name = 'authorization'
|
||||
value = ls_auth-authorization ).
|
||||
ii_client->propertytype_logon_popup = ii_client->co_disabled.
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
@ -116,13 +108,9 @@ CLASS ZCL_ABAPGIT_LOGIN_MANAGER IMPLEMENTATION.
|
|||
|
||||
METHOD save.
|
||||
|
||||
DATA: lv_auth TYPE string.
|
||||
|
||||
lv_auth = ii_client->request->get_header_field( 'authorization' ).
|
||||
|
||||
IF NOT lv_auth IS INITIAL.
|
||||
IF NOT iv_authorization IS INITIAL.
|
||||
append( iv_uri = iv_uri
|
||||
iv_auth = lv_auth ).
|
||||
iv_auth = iv_authorization ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
CLASS ltcl_login_manager DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS: c_username TYPE string VALUE 'Aladdin' ,
|
||||
c_password TYPE string VALUE 'OpenSesame' .
|
||||
CONSTANTS: c_username TYPE string VALUE 'Aladdin',
|
||||
c_password TYPE string VALUE 'OpenSesame'.
|
||||
|
||||
METHODS:
|
||||
setup,
|
||||
teardown,
|
||||
encoding FOR TESTING
|
||||
RAISING zcx_abapgit_exception,
|
||||
same_server FOR TESTING
|
||||
RAISING zcx_abapgit_exception.
|
||||
encoding FOR TESTING RAISING zcx_abapgit_exception,
|
||||
save FOR TESTING RAISING zcx_abapgit_exception,
|
||||
same_server FOR TESTING RAISING zcx_abapgit_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
@ -24,9 +23,24 @@ CLASS ltcl_login_manager IMPLEMENTATION.
|
|||
zcl_abapgit_login_manager=>clear( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD save.
|
||||
|
||||
CONSTANTS lc_uri TYPE string VALUE 'https://abapgit.org/foo/bar'.
|
||||
CONSTANTS lc_auth TYPE string VALUE 'foobar'.
|
||||
|
||||
zcl_abapgit_login_manager=>save(
|
||||
iv_uri = lc_uri
|
||||
iv_authorization = lc_auth ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = zcl_abapgit_login_manager=>get( lc_uri )
|
||||
exp = lc_auth ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD encoding.
|
||||
|
||||
DATA: lv_auth TYPE string.
|
||||
DATA lv_auth TYPE string.
|
||||
|
||||
lv_auth = zcl_abapgit_login_manager=>set(
|
||||
iv_uri = 'https://github.com/abapGit/abapGit.git'
|
||||
|
|
Loading…
Reference in New Issue
Block a user