source: josm/trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuthParametersTest.java@ 18991

Last change on this file since 18991 was 18991, checked in by taylor.smock, 3 months ago

Fix #22810: OSM OAuth 1.0a/Basic auth deprecation and removal

As of 2024-02-15, something changed in the OSM server configuration. This broke
our OAuth 1.0a implementation (see #23475). As such, we are removing OAuth 1.0a
from JOSM now instead of when the OSM server removes support in June 2024.

For third-party OpenStreetMap servers, the Basic Authentication method has been
kept. However, they should be made aware that it may be removed if a non-trivial
bug occurs with it. We highly recommend that the third-party servers update to
the current OpenStreetMap website implementation (if only for their own security).

Failing that, the third-party server can implement RFC8414. As of this commit,
we currently use the authorization_endpoint and token_endpoint fields.
To check and see if their third-party server implements RFC8414, they can go
to <server host>/.well-known/oauth-authorization-server.

Prominent third-party OpenStreetMap servers may give us a client id for their
specific server. That client id may be added to the hard-coded client id list
at maintainer discretion. At a minimum, the server must be publicly
available and have a significant user base.

File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.oauth;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertNotEquals;
6import static org.junit.jupiter.api.Assertions.assertNotNull;
7
8import org.junit.jupiter.api.Test;
9import org.openstreetmap.josm.TestUtils;
10import org.openstreetmap.josm.spi.preferences.Config;
11import org.openstreetmap.josm.tools.Logging;
12
13import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
14import nl.jqno.equalsverifier.EqualsVerifier;
15
16/**
17 * Unit tests for class {@link OAuthParameters}.
18 */
19class OAuthParametersTest {
20 /**
21 * Unit test of method {@link OAuthParameters#createDefault}.
22 */
23 @Test
24 @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
25 void testCreateDefault() {
26 IOAuthParameters def = OAuthParameters.createDefault();
27 assertNotNull(def);
28 assertEquals(def, OAuthParameters.createDefault(Config.getUrls().getDefaultOsmApiUrl(), OAuthVersion.OAuth20));
29 IOAuthParameters dev = OAuthParameters.createDefault("https://api06.dev.openstreetmap.org/api", OAuthVersion.OAuth20);
30 assertNotNull(dev);
31 assertNotEquals(def, dev);
32 Logging.setLogLevel(Logging.LEVEL_TRACE); // enable trace for line coverage
33 assertEquals(def, OAuthParameters.createDefault("wrong_url", OAuthVersion.OAuth20));
34 }
35
36 /**
37 * Unit test of methods {@link OAuthParameters#equals} and {@link OAuthParameters#hashCode}.
38 */
39 @Test
40 void testEqualsContract() {
41 TestUtils.assumeWorkingEqualsVerifier();
42 EqualsVerifier.forClass(OAuth20Parameters.class).usingGetClass().verify();
43 }
44}
Note: See TracBrowser for help on using the repository browser.