Changeset 19654 in josm
- Timestamp:
- 2026-10-22T17:10:19+02:00 (9 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/io/OsmConnectionTest.java
r19638 r19654 9 9 10 10 import java.net.MalformedURLException; 11 import java.net.UR L;11 import java.net.URI; 12 12 13 13 import javax.swing.JOptionPane; … … 60 60 61 61 private static HttpClient apiRequest() throws MalformedURLException { 62 return HttpClient.create( new URL(API_URL + "/0.6/changeset/create"), "PUT");62 return HttpClient.create(URI.create(API_URL + "/0.6/changeset/create").toURL(), "PUT"); 63 63 } 64 64 … … 67 67 */ 68 68 private static OAuth20Parameters rememberParameters() { 69 OAuth20Parameters parameters = new OAuth20Parameters(CLIENT_ID, null, API_URL, API_URL, REDIRECT_URI); 69 final OAuth20Parameters parameters = new OAuth20Parameters(CLIENT_ID, null, API_URL, API_URL, REDIRECT_URI); 70 70 parameters.rememberPreferences(); 71 71 return parameters; … … 82 82 @Test 83 83 void testOAuthParametersComeFromTheApiUrl() throws Exception { 84 OAuth20Parameters parameters = rememberParameters(); 84 final OAuth20Parameters parameters = rememberParameters(); 85 85 // a token is needed, otherwise the connection would try to obtain one 86 86 OAuthAccessTokenHolder.getInstance().setAccessToken(API_URL, new OAuth20Token(parameters, 87 87 "{\"token_type\":\"bearer\", \"access_token\":\"a-token\"}")); 88 88 89 TestConnection connection = new TestConnection(); 89 final TestConnection connection = new TestConnection(); 90 90 assertNull(connection.parameters()); 91 HttpClient client = apiRequest(); 91 final HttpClient client = apiRequest(); 92 92 connection.addOAuth20AuthorizationHeader(client); 93 93 … … 111 111 112 112 // no parameters remembered for this API, and it has no client id built into JOSM 113 HttpClient client = apiRequest(); 114 MissingOAuthAccessTokenException thrown = assertThrows(MissingOAuthAccessTokenException.class, 113 final HttpClient client = apiRequest(); 114 final MissingOAuthAccessTokenException thrown = assertThrows(MissingOAuthAccessTokenException.class, 115 115 () -> new TestConnection().addOAuth20AuthorizationHeader(client)); 116 116 assertNotNull(thrown.getMessage(), "gave up only after asking the user, rather than for the missing client id"); … … 126 126 @Test 127 127 void testExistingTokenSignsTheConnection() throws Exception { 128 OAuth20Parameters parameters = new OAuth20Parameters(CLIENT_ID, null, API_URL, API_URL, REDIRECT_URI); 128 final OAuth20Parameters parameters = new OAuth20Parameters(CLIENT_ID, null, API_URL, API_URL, REDIRECT_URI); 129 129 OAuthAccessTokenHolder.getInstance().setAccessToken(API_URL, new OAuth20Token(parameters, 130 130 "{\"token_type\":\"bearer\", \"access_token\":\"another-token\"}")); 131 131 132 HttpClient client = apiRequest(); 132 final HttpClient client = apiRequest(); 133 133 new TestConnection().addOAuth20AuthorizationHeader(client); 134 134 assertEquals("Bearer another-token", client.getRequestHeader("Authorization"));
Note:
See TracChangeset
for help on using the changeset viewer.
