firebase-admin-go icon indicating copy to clipboard operation
firebase-admin-go copied to clipboard

FR(rtdb): Support for the emulator on http/localhost

Open redaphid opened this issue 6 years ago • 10 comments
trafficstars

Step 3

I'd like to do some integration testing on my local machine for the Realtime Database that's as close to the real thing as possible. I'm trying to use the emulator for this purpose.

Which would probably work, except that NewClient() in db.go enforces https and the url suffix ".firebaseio.com".

Steps to reproduce:

calling DatabaseWithURL() with http://localhost:9000 produces an error.

Relevant Code:

The validation step causing me trouble is here:

func NewClient(ctx context.Context, c *internal.DatabaseConfig) (*Client, error) {
	p, err := url.ParseRequestURI(c.URL)
	if err != nil {
		return nil, err
	} else if p.Scheme != "https" {
		return nil, fmt.Errorf("invalid database URL: %q; want scheme: %q", c.URL, "https")
	} else if !strings.HasSuffix(p.Host, ".firebaseio.com") {
		return nil, fmt.Errorf("invalid database URL: %q; want host: %q", c.URL, "firebaseio.com")
	}

Let me know if there's any other way to connect to the emulator that I missed!

redaphid avatar Nov 07 '19 01:11 redaphid

...and also here:

	return &Client{
		hc:           hc,
		url:          fmt.Sprintf("https://%s", p.Host),
		authOverride: string(ao),
	}, nil

redaphid avatar Nov 07 '19 01:11 redaphid

The Go SDK doesn't support the emulator at the moment. That needs more work (just fixing URL validation is not enough). We already did this in Python: https://github.com/firebase/firebase-admin-python/pull/313. Similar changes are required here.

hiranya911 avatar Nov 07 '19 18:11 hiranya911

Any update on this feature? We're unable to create offline development environments without this or integration tests.

adrianduke avatar Jul 14 '20 13:07 adrianduke

This is now internally tracked as b/136271028 and we'll see if we can get it prioritized. In the meantime, we welcome any Pull Requests on this.

yuchenshi avatar Jul 14 '20 18:07 yuchenshi

Any update on this?

boosh avatar Jun 05 '21 18:06 boosh

It's been a whole year since the post about it being tracked as b/136271028, is there any update on this feature?

nitaigao avatar Jun 30 '21 16:06 nitaigao

+1

timothyleung1 avatar Aug 02 '21 06:08 timothyleung1

+1

arkanjoms avatar Sep 23 '21 00:09 arkanjoms

It looks like @kenshin54 made a PR, can this be merged? Would be really nice to be able to use the database emulator!

wesselvanderlinden avatar Apr 23 '22 12:04 wesselvanderlinden

It looks like @kenshin54 made a PR, can this be merged? Would be really nice to be able to use the database emulator!

Agreed!

benmarsden avatar Apr 26 '22 13:04 benmarsden

Referenced PR from @kenshin54 was here: https://github.com/firebase/firebase-admin-go/pull/471, but seems to have closed after a period of inactivity.

This feature would help our team quite a bit.

r-LaForge avatar Oct 14 '22 04:10 r-LaForge

With inspiration from @kenshin54 I've taken another look at this here: https://github.com/firebase/firebase-admin-go/pull/517

r-LaForge avatar Oct 14 '22 23:10 r-LaForge

Fixed in #517

lahirumaramba avatar Oct 28 '22 20:10 lahirumaramba