diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/BearerAuthScheme.java b/src/com/owncloud/android/lib/common/authentication/oauth/BearerAuthScheme.java index df7ed6dd..b0104342 100644 --- a/src/com/owncloud/android/lib/common/authentication/oauth/BearerAuthScheme.java +++ b/src/com/owncloud/android/lib/common/authentication/oauth/BearerAuthScheme.java @@ -34,8 +34,6 @@ import org.apache.commons.httpclient.auth.AuthenticationException; import org.apache.commons.httpclient.auth.InvalidCredentialsException; import org.apache.commons.httpclient.auth.MalformedChallengeException; -import com.owncloud.android.lib.common.utils.Log_OC; - /** @@ -125,9 +123,7 @@ public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ { * @return A bearer authorization string */ public String authenticate(Credentials credentials, String method, String uri) throws AuthenticationException { - Log_OC.d(TAG, "enter BearerScheme.authenticate(Credentials, String, String)"); - - BearerCredentials bearer = null; + BearerCredentials bearer; try { bearer = (BearerCredentials) credentials; } catch (ClassCastException e) { @@ -160,8 +156,6 @@ public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ { * @return a basic authorization string */ public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { - Log_OC.d(TAG, "enter BearerScheme.authenticate(Credentials, HttpMethod)"); - if (method == null) { throw new IllegalArgumentException("Method may not be null"); } @@ -202,7 +196,6 @@ public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ { * @since 3.0 */ public static String authenticate(BearerCredentials credentials, String charset) { - Log_OC.d(TAG, "enter BearerAuthScheme.authenticate(BearerCredentials, String)"); if (credentials == null) { throw new IllegalArgumentException("Credentials may not be null"); @@ -213,14 +206,7 @@ public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ { StringBuffer buffer = new StringBuffer(); buffer.append(credentials.getAccessToken()); - Log_OC.v(TAG, "OAUTH2: string to authorize: " + "Bearer " + buffer.toString()); return "Bearer " + buffer.toString(); - //return "Bearer " + EncodingUtil.getAsciiString(EncodingUtil.getBytes(buffer.toString(), charset)); - /*return "Bearer " + EncodingUtil.getAsciiString( - Base64.encodeBase64( - EncodingUtil.getBytes(buffer.toString(), charset) - ) - );*/ } /** diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java index 244b5da8..24814167 100644 --- a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java +++ b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java @@ -45,7 +45,7 @@ public class OAuth2ClientConfiguration { } public void setClientId(String clientId) { - mClientId = clientId; + mClientId = (clientId == null) ? "" : clientId; } public String getClientSecret() { @@ -53,7 +53,7 @@ public class OAuth2ClientConfiguration { } public void setClientSecret(String clientSecret) { - mClientSecret = clientSecret; + mClientSecret = (clientSecret == null) ? "" : clientSecret; } public String getRedirectUri() { @@ -61,6 +61,6 @@ public class OAuth2ClientConfiguration { } public void setRedirectUri(String redirectUri) { - this.mRedirectUri = redirectUri; + this.mRedirectUri = (redirectUri == null) ? "" : redirectUri; } } diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java index 2e2611de..33b3c8b5 100644 --- a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java +++ b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java @@ -54,7 +54,7 @@ public class OAuth2GetAccessTokenOperation extends RemoteOperation { private String mRedirectUri; private final String mAccessTokenEndpointPath; - private Map mResultTokenMap; + private final OAuth2ResponseParser mResponseParser; public OAuth2GetAccessTokenOperation( @@ -76,15 +76,10 @@ public class OAuth2GetAccessTokenOperation extends RemoteOperation { accessTokenEndpointPath : OwnCloudOAuth2Provider.ACCESS_TOKEN_ENDPOINT_PATH ; - mResultTokenMap = null; + + mResponseParser = new OAuth2ResponseParser(); } - /* - public Map getResultTokenMap() { - return mResultTokenMap; - } - */ - @Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result = null; @@ -115,15 +110,16 @@ public class OAuth2GetAccessTokenOperation extends RemoteOperation { String response = postMethod.getResponseBodyAsString(); if (response != null && response.length() > 0) { JSONObject tokenJson = new JSONObject(response); - parseAccessTokenResult(tokenJson); - if (mResultTokenMap.get(OAuth2Constants.KEY_ERROR) != null || - mResultTokenMap.get(OAuth2Constants.KEY_ACCESS_TOKEN) == null) { + Map accessTokenResult = + mResponseParser.parseAccessTokenResult(tokenJson); + if (accessTokenResult.get(OAuth2Constants.KEY_ERROR) != null || + accessTokenResult.get(OAuth2Constants.KEY_ACCESS_TOKEN) == null) { result = new RemoteOperationResult(ResultCode.OAUTH2_ERROR); } else { result = new RemoteOperationResult(true, postMethod); ArrayList data = new ArrayList<>(); - data.add(mResultTokenMap); + data.add(accessTokenResult); result.setData(data); } @@ -138,82 +134,15 @@ public class OAuth2GetAccessTokenOperation extends RemoteOperation { } finally { if (postMethod != null) postMethod.releaseConnection(); // let the connection available for other methods - - /* - if (result.isSuccess()) { - Log_OC.i(TAG, "OAuth2 TOKEN REQUEST with auth code " + - mCode + " to " + - client.getWebdavUri() + ": " + result.getLogMessage()); - - } else if (result.getException() != null) { - Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + - mCode + " to " + client. - getWebdavUri() + ": " + result.getLogMessage(), result.getException()); - - } else if (result.getCode() == ResultCode.OAUTH2_ERROR) { - Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + - mCode + " to " + client. - getWebdavUri() + ": " + ((mResultTokenMap != null) ? mResultTokenMap. - get(OAuth2Constants.KEY_ERROR) : "NULL")); - - } else { - Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + - mCode + " to " + client. - getWebdavUri() + ": " + result.getLogMessage()); - } - */ } return result; } private OwnCloudCredentials switchClientCredentials(OwnCloudCredentials newCredentials) { - // work-around for POC with owncloud/oauth2 app, that doesn't allow client OwnCloudCredentials previousCredentials = getClient().getCredentials(); getClient().setCredentials(newCredentials); return previousCredentials; } - - private void parseAccessTokenResult (JSONObject tokenJson) throws JSONException { - mResultTokenMap = new HashMap<>(); - - if (tokenJson.has(OAuth2Constants.KEY_ACCESS_TOKEN)) { - mResultTokenMap.put(OAuth2Constants.KEY_ACCESS_TOKEN, tokenJson. - getString(OAuth2Constants.KEY_ACCESS_TOKEN)); - } - if (tokenJson.has(OAuth2Constants.KEY_TOKEN_TYPE)) { - mResultTokenMap.put(OAuth2Constants.KEY_TOKEN_TYPE, tokenJson. - getString(OAuth2Constants.KEY_TOKEN_TYPE)); - } - if (tokenJson.has(OAuth2Constants.KEY_EXPIRES_IN)) { - mResultTokenMap.put(OAuth2Constants.KEY_EXPIRES_IN, tokenJson. - getString(OAuth2Constants.KEY_EXPIRES_IN)); - } - if (tokenJson.has(OAuth2Constants.KEY_REFRESH_TOKEN)) { - mResultTokenMap.put(OAuth2Constants.KEY_REFRESH_TOKEN, tokenJson. - getString(OAuth2Constants.KEY_REFRESH_TOKEN)); - } - if (tokenJson.has(OAuth2Constants.KEY_SCOPE)) { - mResultTokenMap.put(OAuth2Constants.KEY_SCOPE, tokenJson. - getString(OAuth2Constants.KEY_SCOPE)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR)) { - mResultTokenMap.put(OAuth2Constants.KEY_ERROR, tokenJson. - getString(OAuth2Constants.KEY_ERROR)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR_DESCRIPTION)) { - mResultTokenMap.put(OAuth2Constants.KEY_ERROR_DESCRIPTION, tokenJson. - getString(OAuth2Constants.KEY_ERROR_DESCRIPTION)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR_URI)) { - mResultTokenMap.put(OAuth2Constants.KEY_ERROR_URI, tokenJson. - getString(OAuth2Constants.KEY_ERROR_URI)); - } - - if (tokenJson.has(OAuth2Constants.KEY_USER_ID)) { // not standard - mResultTokenMap.put(OAuth2Constants.KEY_USER_ID, tokenJson. - getString(OAuth2Constants.KEY_USER_ID)); - } - } } diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GrantType.java b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GrantType.java index 2d146958..b9923994 100644 --- a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GrantType.java +++ b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GrantType.java @@ -28,10 +28,11 @@ package com.owncloud.android.lib.common.authentication.oauth; public enum OAuth2GrantType { AUTHORIZATION_CODE("authorization_code"), - REFRESH_TOKEN("refresh_token"), IMPLICIT("implicit"), PASSWORD("password"), - CLIENT_CREDENTIAL("client_credentials"); + CLIENT_CREDENTIAL("client_credentials"), + REFRESH_TOKEN("refresh_token") // not a grant type conceptually, but used as such to refresh access tokens + ; private String mValue; diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetRefreshedAccessTokenOperation.java b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java similarity index 52% rename from src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetRefreshedAccessTokenOperation.java rename to src/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java index 962b3619..cbdb48b1 100644 --- a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetRefreshedAccessTokenOperation.java +++ b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java @@ -33,45 +33,41 @@ import com.owncloud.android.lib.common.utils.Log_OC; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.methods.PostMethod; -import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; -import java.util.HashMap; import java.util.Map; -public class OAuth2GetRefreshedAccessTokenOperation extends RemoteOperation { +public class OAuth2RefreshAccessTokenOperation extends RemoteOperation { - private static final String TAG = OAuth2GetRefreshedAccessTokenOperation.class.getSimpleName(); + private static final String TAG = OAuth2RefreshAccessTokenOperation.class.getSimpleName(); - private String mGrantType; private String mClientId; private String mClientSecret; private String mRefreshToken; - private Map mResultTokenMap; private final String mAccessTokenEndpointPath; + private final OAuth2ResponseParser mResponseParser; - public OAuth2GetRefreshedAccessTokenOperation( - String grantType, + public OAuth2RefreshAccessTokenOperation( String clientId, String secretId, String refreshToken, String accessTokenEndpointPath ) { - mGrantType = grantType; mClientId = clientId; mClientSecret = secretId; mRefreshToken = refreshToken; - mResultTokenMap = null; mAccessTokenEndpointPath = accessTokenEndpointPath != null ? accessTokenEndpointPath : OwnCloudOAuth2Provider.ACCESS_TOKEN_ENDPOINT_PATH ; + + mResponseParser = new OAuth2ResponseParser(); } @Override @@ -82,7 +78,10 @@ public class OAuth2GetRefreshedAccessTokenOperation extends RemoteOperation { try { NameValuePair[] nameValuePairs = new NameValuePair[3]; - nameValuePairs[0] = new NameValuePair(OAuth2Constants.KEY_GRANT_TYPE, mGrantType); + nameValuePairs[0] = new NameValuePair( + OAuth2Constants.KEY_GRANT_TYPE, + OAuth2GrantType.REFRESH_TOKEN.getValue() // always for this operation + ); nameValuePairs[1] = new NameValuePair(OAuth2Constants.KEY_CLIENT_ID, mClientId); nameValuePairs[2] = new NameValuePair(OAuth2Constants.KEY_REFRESH_TOKEN, mRefreshToken); @@ -108,15 +107,16 @@ public class OAuth2GetRefreshedAccessTokenOperation extends RemoteOperation { if (response != null && response.length() > 0) { JSONObject tokenJson = new JSONObject(response); - parseNewAccessTokenResult(tokenJson); - if (mResultTokenMap.get(OAuth2Constants.KEY_ERROR) != null || - mResultTokenMap.get(OAuth2Constants.KEY_ACCESS_TOKEN) == null) { + Map accessTokenResult = + mResponseParser.parseAccessTokenResult(tokenJson); + if (accessTokenResult.get(OAuth2Constants.KEY_ERROR) != null || + accessTokenResult.get(OAuth2Constants.KEY_ACCESS_TOKEN) == null) { result = new RemoteOperationResult(ResultCode.OAUTH2_ERROR); } else { result = new RemoteOperationResult(true, postMethod); ArrayList data = new ArrayList<>(); - data.add(mResultTokenMap); + data.add(accessTokenResult); result.setData(data); } @@ -129,83 +129,18 @@ public class OAuth2GetRefreshedAccessTokenOperation extends RemoteOperation { result = new RemoteOperationResult(e); } finally { - if (postMethod != null) + if (postMethod != null) { postMethod.releaseConnection(); // let the connection available for other methods - - /* - if (result.isSuccess()) { - Log_OC.i(TAG, "OAuth2 TOKEN REQUEST with refresh token " + - mRefreshToken + " to " + - client.getWebdavUri() + ": " + result.getLogMessage()); - - } else if (result.getException() != null) { - Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with refresh token " + - mRefreshToken + " to " + client. - getWebdavUri() + ": " + result.getLogMessage(), result.getException()); - - } else if (result.getCode() == ResultCode.OAUTH2_ERROR) { - Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with refresh token " + - mRefreshToken + " to " + client. - getWebdavUri() + ": " + ((mResultTokenMap != null) ? mResultTokenMap. - get(OAuth2Constants.KEY_ERROR) : "NULL")); - - } else { - Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with refresh token " + - mRefreshToken + " to " + client. - getWebdavUri() + ": " + result.getLogMessage()); } - */ } return result; } private OwnCloudCredentials switchClientCredentials(OwnCloudCredentials newCredentials) { - // work-around for POC with owncloud/oauth2 app, that doesn't allow client OwnCloudCredentials previousCredentials = getClient().getCredentials(); getClient().setCredentials(newCredentials); return previousCredentials; } - private void parseNewAccessTokenResult(JSONObject tokenJson) throws JSONException { - mResultTokenMap = new HashMap<>(); - - if (tokenJson.has(OAuth2Constants.KEY_ACCESS_TOKEN)) { - mResultTokenMap.put(OAuth2Constants.KEY_ACCESS_TOKEN, tokenJson. - getString(OAuth2Constants.KEY_ACCESS_TOKEN)); - } - if (tokenJson.has(OAuth2Constants.KEY_TOKEN_TYPE)) { - mResultTokenMap.put(OAuth2Constants.KEY_TOKEN_TYPE, tokenJson. - getString(OAuth2Constants.KEY_TOKEN_TYPE)); - } - if (tokenJson.has(OAuth2Constants.KEY_EXPIRES_IN)) { - mResultTokenMap.put(OAuth2Constants.KEY_EXPIRES_IN, tokenJson. - getString(OAuth2Constants.KEY_EXPIRES_IN)); - } - if (tokenJson.has(OAuth2Constants.KEY_REFRESH_TOKEN)) { - mResultTokenMap.put(OAuth2Constants.KEY_REFRESH_TOKEN, tokenJson. - getString(OAuth2Constants.KEY_REFRESH_TOKEN)); - } - if (tokenJson.has(OAuth2Constants.KEY_SCOPE)) { - mResultTokenMap.put(OAuth2Constants.KEY_SCOPE, tokenJson. - getString(OAuth2Constants.KEY_SCOPE)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR)) { - mResultTokenMap.put(OAuth2Constants.KEY_ERROR, tokenJson. - getString(OAuth2Constants.KEY_ERROR)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR_DESCRIPTION)) { - mResultTokenMap.put(OAuth2Constants.KEY_ERROR_DESCRIPTION, tokenJson. - getString(OAuth2Constants.KEY_ERROR_DESCRIPTION)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR_URI)) { - mResultTokenMap.put(OAuth2Constants.KEY_ERROR_URI, tokenJson. - getString(OAuth2Constants.KEY_ERROR_URI)); - } - - if (tokenJson.has(OAuth2Constants.KEY_USER_ID)) { // not standard - mResultTokenMap.put(OAuth2Constants.KEY_USER_ID, tokenJson. - getString(OAuth2Constants.KEY_USER_ID)); - } - } } \ No newline at end of file diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2ResponseParser.java b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2ResponseParser.java new file mode 100644 index 00000000..068165f2 --- /dev/null +++ b/src/com/owncloud/android/lib/common/authentication/oauth/OAuth2ResponseParser.java @@ -0,0 +1,77 @@ +/** + * ownCloud Android client application + * + * @author David A. Velasco + * + * Copyright (C) 2017 ownCloud GmbH. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package com.owncloud.android.lib.common.authentication.oauth; + + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +class OAuth2ResponseParser { + + Map parseAccessTokenResult(JSONObject tokenJson) throws JSONException { + Map resultTokenMap = new HashMap<>(); + + if (tokenJson.has(OAuth2Constants.KEY_ACCESS_TOKEN)) { + resultTokenMap.put(OAuth2Constants.KEY_ACCESS_TOKEN, tokenJson. + getString(OAuth2Constants.KEY_ACCESS_TOKEN)); + } + if (tokenJson.has(OAuth2Constants.KEY_TOKEN_TYPE)) { + resultTokenMap.put(OAuth2Constants.KEY_TOKEN_TYPE, tokenJson. + getString(OAuth2Constants.KEY_TOKEN_TYPE)); + } + if (tokenJson.has(OAuth2Constants.KEY_EXPIRES_IN)) { + resultTokenMap.put(OAuth2Constants.KEY_EXPIRES_IN, tokenJson. + getString(OAuth2Constants.KEY_EXPIRES_IN)); + } + if (tokenJson.has(OAuth2Constants.KEY_REFRESH_TOKEN)) { + resultTokenMap.put(OAuth2Constants.KEY_REFRESH_TOKEN, tokenJson. + getString(OAuth2Constants.KEY_REFRESH_TOKEN)); + } + if (tokenJson.has(OAuth2Constants.KEY_SCOPE)) { + resultTokenMap.put(OAuth2Constants.KEY_SCOPE, tokenJson. + getString(OAuth2Constants.KEY_SCOPE)); + } + if (tokenJson.has(OAuth2Constants.KEY_ERROR)) { + resultTokenMap.put(OAuth2Constants.KEY_ERROR, tokenJson. + getString(OAuth2Constants.KEY_ERROR)); + } + if (tokenJson.has(OAuth2Constants.KEY_ERROR_DESCRIPTION)) { + resultTokenMap.put(OAuth2Constants.KEY_ERROR_DESCRIPTION, tokenJson. + getString(OAuth2Constants.KEY_ERROR_DESCRIPTION)); + } + if (tokenJson.has(OAuth2Constants.KEY_ERROR_URI)) { + resultTokenMap.put(OAuth2Constants.KEY_ERROR_URI, tokenJson. + getString(OAuth2Constants.KEY_ERROR_URI)); + } + + if (tokenJson.has(OAuth2Constants.KEY_USER_ID)) { // not standard + resultTokenMap.put(OAuth2Constants.KEY_USER_ID, tokenJson. + getString(OAuth2Constants.KEY_USER_ID)); + } + + return resultTokenMap; + } + +} diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2RequestBuilder.java b/src/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2RequestBuilder.java index 84c1bf85..18933824 100644 --- a/src/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2RequestBuilder.java +++ b/src/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2RequestBuilder.java @@ -87,8 +87,7 @@ public class OwnCloudOAuth2RequestBuilder implements OAuth2RequestBuilder { ); case REFRESH_ACCESS_TOKEN: - return new OAuth2GetRefreshedAccessTokenOperation( - mGrantType.getValue(), + return new OAuth2RefreshAccessTokenOperation( clientConfiguration.getClientId(), clientConfiguration.getClientSecret(), mRefreshToken, diff --git a/src/com/owncloud/android/lib/common/operations/RemoteOperation.java b/src/com/owncloud/android/lib/common/operations/RemoteOperation.java index 23fe299f..f059bfe5 100644 --- a/src/com/owncloud/android/lib/common/operations/RemoteOperation.java +++ b/src/com/owncloud/android/lib/common/operations/RemoteOperation.java @@ -189,10 +189,10 @@ public abstract class RemoteOperation implements Runnable { if (context == null) throw new IllegalArgumentException ("Trying to execute a remote operation with a NULL Context"); + // mAccount and mContext in the runnerThread to create below mAccount = account; mContext = context.getApplicationContext(); mClient = null; // the client instance will be created from - // mAccount and mContext in the runnerThread to create below mListener = listener; diff --git a/test_client/res/values/setup.xml b/test_client/res/values/setup.xml index 0f4c5c70..3fc22fe1 100644 --- a/test_client/res/values/setup.xml +++ b/test_client/res/values/setup.xml @@ -25,9 +25,9 @@ - - - - + https://qa.oc.solidgear.es + https://qa2.oc.solidgear.es + android-library-test + letitgo,letitgo,thatperfectappisgone Mozilla/5.0 (Android) ownCloud test project diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/OwnCloudClientTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/OwnCloudClientTest.java index fd74b252..8210c3de 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/OwnCloudClientTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/OwnCloudClientTest.java @@ -130,7 +130,7 @@ public class OwnCloudClientTest extends AndroidTestCase { client.setCredentials(credentials); assertEquals("Basic credentials not set", credentials, client.getCredentials()); - credentials = OwnCloudCredentialsFactory.newBearerCredentials("bearerToken"); + credentials = OwnCloudCredentialsFactory.newBearerCredentials("user", "bearerToken"); client.setCredentials(credentials); assertEquals("Bearer credentials not set", credentials, client.getCredentials()); @@ -294,7 +294,7 @@ public class OwnCloudClientTest extends AndroidTestCase { public void testGetWebdavUri() { OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager()); - client.setCredentials(OwnCloudCredentialsFactory.newBearerCredentials("fakeToken")); + client.setCredentials(OwnCloudCredentialsFactory.newBearerCredentials("user", "fakeToken")); Uri webdavUri = client.getWebdavUri(); assertTrue("WebDAV URI does not point to the right entry point", webdavUri.getPath().endsWith(AccountUtils.WEBDAV_PATH_4_0));