
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 d Z
d	 Zd
 Zd Zd Zd Zd Zd Zy)zBHelper methods for configuring web security scanner command flags.    )absolute_import)division)unicode_literals)wss_base)base)
exceptionsc                      t        j                  d      } | j                  t                      | j                  t	                      | j                  t                      | j                  t                      | gS )zOHook to add additional authentication flags.

  Returns:
    Auth flag group
  F)mutex)r   ArgumentGroupAddArgument	_TypeFlag	_UserFlag_PasswordFlag_UrlFlag)
auth_groups    ;lib/googlecloudsdk/command_lib/web_security_scanner/auth.py	AuthFlagsr      s\     !!.*%%)$
    c                  :    t        j                  dddddd      S )z(Returns a flag for setting an auth type.--auth-typezDisables Authentication.z%Authentication with a Google account.z%Authentication with a custom account.)nonegooglecustomzType of authentication to use.)choiceshelp_str)r   ChoiceArgument r   r   r   r   (   s+    			,;;
 0
 r   c                  0    t        j                  dd      S )z(Returns a flag for setting an auth user.z--auth-userz      The test user to log in as. Required if `--auth-type` is not 'none'.
      'google' login requires a full email address. Cannot be your own account.
      helpr   Argumentr   r   r   r   r   5   s    	

 r   c                  0    t        j                  dd      S )z,Returns a flag for setting an auth password.z--auth-passwordzQ      Password for the test user. Required if `--auth-type` is not 'none'.
      r   r!   r   r   r   r   r   ?   s    	

 r   c                  0    t        j                  dd      S )z'Returns a flag for setting an auth url.z
--auth-urlz      URL of the login page for your site. Required if `--auth-type` is
      'custom'. Otherwise, it should not be set.
      r   r!   r   r   r   r   r   H   s    	

 r   c                    t        j                         }|j                  Dt        |j                  |j
                  |j                  g      rt        j                  dd      |S |j                  dk(  rDt        |j                  |j
                  |j                  g      rt        j                  dd      |S |j                  |j                  j                         |_
        |j                  j                         |j                  _        |j                  dk(  r[t        |ddgd       |j                  j!                  |j                  |j
                        |j                  j                  _        |S |j                  d	k(  rft        |g d
d	       |j                  j%                  |j                  |j
                  |j                        |j                  j                  _        |S t        j(                  d|j                        )a  Modify request hook to set scan config details.

  Args:
    unused_ref: not used parameter to modify request hooks
    args: Parsed args namespace
    request: The partially filled request object.

  Returns:
    Request object with Authentication message filled out.
  r   z+Required when setting authentication flags.r   z4No other auth flags can be set with --auth-type=noner   	auth_userauth_password)usernamepasswordr   )r&   r'   auth_url)r(   r)   loginUrl)r   WebSecurityScannerCommand	auth_typeanyr&   r'   r*   r   RequiredArgumentExceptionInvalidArgumentException
scanConfigmessages
ScanConfigAuthenticationauthentication"_RequireAllFlagsOrRaiseForAuthTypeGoogleAccountgoogleAccountCustomAccountcustomAccountUnknownArgumentException)
unused_refargsrequestcs       r   SetScanConfigAuthr@   R   s    ((*!	^^
DNND..>?00
FH HN	^^v
DNND..>?//
OQ QN..0G&'jj&?&?&A'#	^^x&tk?-K'/167jj6N6N$*<*< 7O 7>G%%3 
. ~~!&8(D67jj6N6N## 7O 7 G%%3 
. 
-
-mT^^
LLr   c                 v    |j                   |S |j                  r|xj                  dz  c_        |S d|_        |S )z%Adds auth-specific fieldmask entries.z,authenticationr5   )r-   
updateMask)r<   r=   r>   s      r   AddAuthFieldMaskrC      sB    	^^N++ 
. *G	.r   c                     t        |       }|D ]M  }||   	|j                  dd      }t        j                  dj	                  |      dj	                  |             y )N_-z--{0}zRequired by --auth-type={0})varsreplacer   r/   format)r=   flagsr-   argvarsflagdasheds         r   r6   r6      s\    J'dt}||C%f00
..
 
'
.
.y
9; ; r   N)__doc__
__future__r   r   r   +googlecloudsdk.api_lib.web_security_scannerr   googlecloudsdk.callioper   r   r   r   r   r   r   r@   rC   r6   r   r   r   <module>rR      sF    I &  ' @ ( .
*Z
;r   