Skip to content

Commit

Permalink
fix(:bug:): treat ArcGIS Online orgs as equivalent to arcgis.com when…
Browse files Browse the repository at this point in the history
… testing a portal

AFFECTS PACKAGES:
@esri/arcgis-rest-auth

ISSUES CLOSED: #233
  • Loading branch information
jgravois committed Jul 16, 2018
1 parent 8c40b72 commit 18c3a7f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/arcgis-rest-auth/src/UserSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ export class UserSession implements IAuthenticationManager {
*/
getToken(url: string) {
if (
/^https?:\/\/www\.arcgis\.com\/sharing\/rest\/?/.test(this.portal) &&
/^https?:\/\/\S+\.maps.arcgis\.com\/sharing\/rest|^https?:\/\/www\.arcgis\.com\/sharing\/rest/.test(
this.portal
) &&
/^https?:\/\/\S+\.arcgis\.com.+/.test(url)
) {
return this.getFreshToken();
Expand Down
21 changes: 21 additions & 0 deletions packages/arcgis-rest-auth/test/UserSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ describe("UserSession", () => {
});
});

it("should return unexpired tokens when an org url is passed", done => {
const session = new UserSession({
clientId: "id",
token: "token",
tokenExpires: TOMORROW,
portal: "https://custom.maps.arcgis.com/sharing/rest"
});

session
.getToken(
"https://services1.arcgis.com/MOCK_ORG/arcgis/rest/services/Private_Service/FeatureServer"
)
.then(token => {
expect(token).toBe("token");
done();
})
.catch(e => {
fail(e);
});
});

it("should return unexpired tokens for the configured portal domain", done => {
const session = new UserSession({
clientId: "id",
Expand Down

0 comments on commit 18c3a7f

Please sign in to comment.