Skip to content

Commit

Permalink
fix: properly deserialize trustedOrgs from context (#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
benstoltz authored Oct 4, 2023
1 parent bc8106a commit 760b4ff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/common/src/ArcGISContextManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ export class ArcGISContextManager {
if (state.properties) {
opts.properties = state.properties;
}
if (state.trustedOrgIds) {
opts.trustedOrgIds = state.trustedOrgIds;
}
if (state.trustedOrgs) {
opts.trustedOrgs = state.trustedOrgs;
}
}
} else {
// if the session is expired, we can still carry forward the portalUrl
Expand Down
11 changes: 11 additions & 0 deletions packages/common/test/ArcGISContextManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ const serializedContext = {
properties: {
foo: "bar",
},
trustedOrgIds: ["FAKEID", "FOTHERID"],
trustedOrgs: onlinePartneredOrgResponse.trustedOrgs,
};

const validSerializedContext = cloneObject(serializedContext);
Expand Down Expand Up @@ -597,6 +599,13 @@ describe("ArcGISContext:", () => {
validSerializedContext.currentUser
);
expect(mgr.context.session.token).toEqual(validSession.token);
// trusted orgs/ids
expect(mgr.context.trustedOrgIds).toEqual(
validSerializedContext.trustedOrgIds
);
expect(mgr.context.trustedOrgs).toEqual(
validSerializedContext.trustedOrgs
);
});
it("can deserialize sparse, valid context", async () => {
const selfSpy = spyOn(portalModule, "getSelf").and.callFake(() => {
Expand All @@ -612,6 +621,8 @@ describe("ArcGISContext:", () => {
delete sparseValidContext.currentUser;
delete sparseValidContext.portal;
delete sparseValidContext.properties;
delete sparseValidContext.trustedOrgIds;
delete sparseValidContext.trustedOrgs;

const serialized = unicodeToBase64(JSON.stringify(sparseValidContext));
const mgr = await ArcGISContextManager.deserialize(serialized!);
Expand Down

0 comments on commit 760b4ff

Please sign in to comment.