projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '20123-access-token-doc' refs #20123
[arvados.git]
/
services
/
api
/
test
/
integration
/
api_client_authorizations_api_test.rb
diff --git
a/services/api/test/integration/api_client_authorizations_api_test.rb
b/services/api/test/integration/api_client_authorizations_api_test.rb
index 14e3bb361d204af3d61060d443562be660f77f3c..405e4bf687cee646c06e1c22d189802c4039d848 100644
(file)
--- a/
services/api/test/integration/api_client_authorizations_api_test.rb
+++ b/
services/api/test/integration/api_client_authorizations_api_test.rb
@@
-124,7
+124,7
@@
class ApiClientAuthorizationsApiTest < ActionDispatch::IntegrationTest
end
end
end
end
- test "
expires_at can be
set to #{desired_expiration.nil? ? 'nil' : 'exceed the limit'} by admins when API.MaxTokenLifetime is set" do
+ test "
behavior when expires_at is
set to #{desired_expiration.nil? ? 'nil' : 'exceed the limit'} by admins when API.MaxTokenLifetime is set" do
Rails.configuration.API.MaxTokenLifetime = 1.hour
# Test token creation
Rails.configuration.API.MaxTokenLifetime = 1.hour
# Test token creation
@@
-139,31
+139,31
@@
class ApiClientAuthorizationsApiTest < ActionDispatch::IntegrationTest
headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin_trustedclient).api_token}"}
assert_response 200
if desired_expiration.nil?
headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin_trustedclient).api_token}"}
assert_response 200
if desired_expiration.nil?
- assert json_response['expires_at'].nil?
+ # When expires_at is nil, default to MaxTokenLifetime
+ assert_operator (json_response['expires_at'].to_time.to_i - (db_current_time + Rails.configuration.API.MaxTokenLifetime).to_i).abs, :<, 2
else
assert_equal json_response['expires_at'].to_time.to_i, desired_expiration.to_i
end
# Test token update (reverse the above behavior)
else
assert_equal json_response['expires_at'].to_time.to_i, desired_expiration.to_i
end
# Test token update (reverse the above behavior)
- previous_expiration = json_response['expires_at']
token_uuid = json_response['uuid']
token_uuid = json_response['uuid']
- if
previous
_expiration.nil?
-
desir
ed_updated_expiration = db_current_time + Rails.configuration.API.MaxTokenLifetime + 1.hour
+ if
desired
_expiration.nil?
+
submitt
ed_updated_expiration = db_current_time + Rails.configuration.API.MaxTokenLifetime + 1.hour
else
else
-
desir
ed_updated_expiration = nil
+
submitt
ed_updated_expiration = nil
end
put "/arvados/v1/api_client_authorizations/#{token_uuid}",
params: {
:api_client_authorization => {
end
put "/arvados/v1/api_client_authorizations/#{token_uuid}",
params: {
:api_client_authorization => {
- :expires_at =>
desir
ed_updated_expiration,
+ :expires_at =>
submitt
ed_updated_expiration,
}
},
headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin_trustedclient).api_token}"}
assert_response 200
}
},
headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin_trustedclient).api_token}"}
assert_response 200
- if
desir
ed_updated_expiration.nil?
- assert
json_response['expires_at'].nil?
+ if
submitt
ed_updated_expiration.nil?
+ assert
_operator (json_response['expires_at'].to_time.to_i - (db_current_time + Rails.configuration.API.MaxTokenLifetime).to_i).abs, :<, 2
else
else
- assert_equal json_response['expires_at'].to_time.to_i,
desir
ed_updated_expiration.to_i
+ assert_equal json_response['expires_at'].to_time.to_i,
submitt
ed_updated_expiration.to_i
end
end
end
end
end
end