Skip to content

Commit

Permalink
check for key property existence when creating api key objects (#3067)
Browse files Browse the repository at this point in the history
* check for key property existence when creating api key objects

fix apikeys tests
add missing files to binding.gyp

* fix binding.gyp

* add CHANGELOG

* disabled test cause of CI stitch integration
  • Loading branch information
blagoev authored Jul 17, 2020
1 parent bca5a50 commit 1f3c13e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
x.x.x Release notes (yyyy-m-dd)
=============================================================
NOTE: Support for syncing with realm.cloud.io and/or Realm Object Server has been replaced with support for syncing with MongoDB Realm Cloud.

NOTE: This version bumps the Realm file format to version 11. It is not possible to downgrade to earlier versions. Older files will automatically be upgraded to the new file format. Files created by Realm JavaScript prior to v1.0.0, might not be upgradeable. Only [Realm Studio 10.0.0](https://github.com/realm/realm-studio/releases/tag/v10.0.0-beta.1) or later will be able to open the new file format.

### Enhancements
* None.

### Fixed
* A crash when calling `user.apiKeys.fetchAll()`

### Compatibility
* MongoDB Realm Cloud.
* APIs are backwards compatible with all previous releases of Realm JavaScript in the 10.x.y series.
* File format: generates Realms with format v11 (reads and upgrades file format v5 or later).

### Internal
* None.

10.0.0-beta.9 Release notes (2020-7-15)
=============================================================
NOTE: Support for syncing with realm.cloud.io and/or Realm Object Server has been replaced with support for syncing with MongoDB Realm Cloud.
Expand Down
2 changes: 2 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"src/js_user.hpp",
"src/js_network_transport.hpp",
"src/js_email_password_auth.hpp",
"src/js_api_key_auth.hpp",
"src/js_auth.hpp",
"src/node/sync_logger.cpp",
"src/node/sync_logger.hpp",
]
Expand Down
2 changes: 1 addition & 1 deletion src/js_api_key_auth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ typename T::Object make_api_key(typename T::Context ctx, util::Optional<app::App
ObjectType api_key_object = Object<T>::create_empty(ctx);
if (api_key) {
Object<T>::set_property(ctx, api_key_object, "id", Value<T>::from_object_id(ctx, api_key->id));
Object<T>::set_property(ctx, api_key_object, "key", Value<T>::from_string(ctx, *(api_key->key)));
Object<T>::set_property(ctx, api_key_object, "key", api_key->key ? Value<T>::from_string(ctx, *(api_key->key)) : Value<T>::from_undefined(ctx));
Object<T>::set_property(ctx, api_key_object, "name", Value<T>::from_string(ctx, api_key->name));
Object<T>::set_property(ctx, api_key_object, "disabled", Value<T>::from_boolean(ctx, api_key->disabled));
}
Expand Down
7 changes: 6 additions & 1 deletion tests/js/user-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,14 @@ module.exports = {
let user = await app.logIn(credentials);
TestCase.assertTrue(user.apiKeys instanceof Realm.Auth.ApiKeyAuth);

// TODO: Fix this to not respond with a 403
//TODO: Enable when fixed: Disabling this test since the CI stitch integration returns cryptic error.
// const apikey = await user.apiKeys.create("mykey");
// const keys = await user.apiKeys.fetchAll();
// TestCase.assertTrue(Array.isArray(keys));

// TestCase.assertEqual(keys.length, 1);
// TestCase.assertDefined(keys[0].id);
// TestCase.assertEqual(keys[0].name, mykey);

await user.logOut();
},
Expand Down

0 comments on commit 1f3c13e

Please sign in to comment.