feat(auth): Emulator support for CreateCustomTokenAsync() API#293
Merged
Conversation
lahirumaramba
approved these changes
Apr 7, 2021
lahirumaramba
left a comment
Member
There was a problem hiding this comment.
LGTM!
Is there a kid in the header for emulator tokens?
Contributor
Author
|
Custom tokens don't use a |
hiranya911
added a commit
that referenced
this pull request
Apr 13, 2021
* feat(auth): Add support for Firebase Authentication Emulator (#289) * Add IdToolkitHostResolver with tests * Add resolution for versions of the API with tests * Simplify and reduce IdToolkitHostResolver to a Util method * Add TestConfig for testing against FirebaseEmulatorHost Add environment variable test that piggybacks on the already established FirebaseUserManagerTest. Also, to make it easier to access and set environment variables a convenience class has been made to help out. This class utilizes the neat builtin get and set mechanism provided by the C# language. By using this class the code somewhat documents itself and prevents stupid spelling mistakes that might occur when running code. Each environment variable can conveniently be documented inside the class. * Add license for new Utils class file * Add documentation for ResolveIdToolkitHost with examples * Use the EnvironmentVariable class to access env variables * Fix formatting * Use inheritance instead of TestConfig to set FirebaseUserManager tests The TestConfig was not being disposed of when expected resulting in the env variable being set in other tests as well and causing them to fail. * Cleanup and rename variable to more meaningful name * Move Utils and EnvironmentVariable class to Auth namespace * Move emulatorHostEnvVar to where it's used for readability * Rename UtilTest to more appropriate name * Rename expected...Host to expected...Url * Use the FirebaseAuthEmulatorHostName const instead of string * Add missing license head * Add missing util import and fix stylecop complaints * Rename AuthUtil to Util and move to Auth test folder * Simplify emulator host environment variable to be a constant in Utils * Use string literal for emulator host in FirebaseUserManagerTest In case a constant values is changed such as the used environment variable, this will cause the tests to fail, which is good to know. * Remove unnecessary tests from FirebaseAuthTest * Use string literal to ensure test fails if constant is changed * Remove the environment simplification since there is only one callsite * Cleanup GetIdToolkitHost documentation * Correct typo in file name. Util -> Utils. * Rename test cass to UtilsTest * Add tenant resolution to GetIdToolkitHost * Add function for resolving GoogleCredentials when in emulator mode * Add test for tenant url resolution * Use if statement instead of ternary for tenantIdPath * Better formatting for GetIdToolkitHost * Add periods to the end of documentation strings * Remove nullable and provide empty string instead * Change to only have one single line at end * Add convenience funcs for getting and checking emulator host env variable * Simplify GetEmulatorHost name * fix(auth): Setting EmulatorHost programatically (#290) * fix(auth): Setting EmulatorHost programatically * fix: Cleaned up tests * fix: Cleaned up user manager tests * feat(auth): Supporting VerifyIdToken() API with emulator (#291) * feat(auth): Emulator support for CreateCustomTokenAsync() API (#293) * feat(auth): Emulator support for CreateCustomTokenAsync() API * fix: Cleaned up unit tests * fix: Removed extra punctuation * feat(auth): Adding emulator support to TenantManager API (#294) * feat(auth): Adding emulator support to TenantManager API * fix: Updated test to check for credentials Co-authored-by: Bjarke <work.bjarke@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented support for creating custom tokens for the emulator. In the emulator mode:
algheader is set tonone.Bulk of the changes are just refactoring the existing tests. I've updated
CustomTokenTestto be more inline with other test classes likeIdTokenVerificationTest, where we test behavior via parameterization, as opposed to creatingFirebaseAppinstances with different configurations.