authenticate

ウェブ・サービスを使用する前に、HTTP認証スキームとその情報を指定します。
名前説明タイプ修飾子
schema

HTTP認証スキームです。

使用可能な値: 

Value SetBasic, OAuth 2, Digest
value

HTTP認証情報です。( を参照してください)

Stringなし
なし
このアクションは、次のプロジェクト項目で使用できます: テストモジュールおよびユーザー定義アクションです。
次の設定はこのアクションに適用可能です:  remove double quotes from cells.
例1・ベーシック認証スキーム

以下の情報に基づいて特定のAPIをテストを行いたいと仮定します: 

  • 認証スキーム: ベーシック認証スキーム
  • テスト対象のWebサービス: http://192.168.190.212:8091/api/authenticate
  • ユーザー名: john.doe
  • パスワード: R6z,nUjeH];3L4r:
        
        	name	value			
local variable	username	john.doe			
local variable	password	R6z,nUjeH];3L4r:			
local variable	uri	http://192.168.190.212:8091/api/authenticate			
&nbsp					
	schema	value			
authenticate	basic	# username& ":" & password			
&nbsp					
create http request					
&nbsp					
	uri	method	timeout	variable	expected code
send http request	# uri	GET	200	>>response	200
&nbsp					
	response	status	header	body	
parse http response	# response	>>status	>>header	>>body	
        
    
例2・OAuth 2.0認証スキーム

以下の情報に基づいて、特定のGmail APIを使用して全てのメッセージを取得するテストを行いたいと仮定します: 

  • 認証スキーム: OAuth 2.0
  • テスト対象のウェブサービス: Users.messages: get
  • アクセストークン: ya29.Ci-fA76X0cjJXa2Lx0RM-fRyAQ6-6pboEX-iuT7PR-yYV6D-Rfbos7bs151wiL-O7w
    ヒント: 
    Google APIのOAuth 2.0のアクセストークンを取得するために、 こちらを参照してください。
        
        	name	value			
local variable	uri	https://www.googleapis.com/gmail/v1/users/me/messages			
local variable	access token	ya29.Ci-fA76X0cjJXa2Lx0RM-fRyAQ6-6pboEX-iuT7PR-yYV6D-Rfbos7bs151wiL-O7w			
&nbsp					
	schema	value			
authenticate	oauth 2	# access token			
&nbsp					
create http request					
&nbsp					
	key	value			
add http header	Content-Type	application/json			
&nbsp					
	uri	method	timeout	variable	expected code
send http request	# uri	GET	200	>>response	200
&nbsp					
	response	status	header	body	
parse http response	# response	>>status	>>header	>>body	
        
    
例3・ダイジェスト認証スキーム

以下の情報に基づいて特定のAPIをテストしたいと仮定します: 

  • 認証スキーム: ダイジェスト認証スキーム
  • テスト対象のウェブサービス: http://192.168.167.29:8081/api/authenticate
  • ユーザー名: john.doe
  • パスワード: 123
        
        	name	value			
local variable	username	john.doe			
local variable	password	123			
local variable	uri	http://192.168.167.29:8081/api/authenticate			
&nbsp					
	schema	value			
authenticate	digest	# username& ":" & password			
&nbsp					
	uri	method	variable	timeout	expected code
send http request	# uri	GET	>>response	100	200
&nbsp					
	response	status	header	body	
parse http response	# response	>>status	>>header	>>body	
        
    
  • 認証を開始する前に、このビルトインアクションを宣言する必要があります。さらに、このビルトインアクションは、create http request を宣言する前または後にも宣言できます。
  • 引数 value: 選択された認証スキームに依存します。HTTP認証情報を提供するための異なる方法があります。
    1. 基本的なHTTP認証スキームの場合: サービスに認証するためにユーザー名とパスワードを指定します。次のフォーマットに従ってください: userid:password.
      ヒント: 
      プレーンテキスト文字列またはBase64URLエンコードされた文字列を入力できます。テキスト文字列をBase64URLエンコードされた文字列にエンコードするには、Online Base64URL encoder を使用できます。
      例えば、ユーザー名がJohnでパスワードがDoeの場合、以下のようになります。
      • プレーンテキスト文字列: John:Doe
      • Base64URLエンコードされた文字列: Sm9objpEb2U
    2. OAuth 2.0スキームの場合: OAuthで保護されたリソースにアクセスするために必要なアクセストークンを指定します。例えば: ya29.Ci-fA76X0cjJXa2Lx0RM-fRyAQ6-6pboEX-iuT7PR-yYV6D-Rfbos7bs151wiL-O7w
    3. Digest認証スキームの場合: サービスに認証するために、ユーザー名とパスワードを含む2つのフィールドを指定します。次のフォーマットに従ってください: username:password.
  • このアクションは <ignore> 修飾子をサポートしています。引数のいずれかの値として文字列 <ignore> が含まれているか、或いはどの引数かが <ignore> に評価される式を含んでいる場合、そのアクションは実行中にスキップされます。

Copyright © 2023 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1(800) 322-0333