-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: NWA auth for self-hosted hubs (#1016)
* feat: nwc create_connection command (WIP) * feat: allow creating superuser apps from the ui * fix: pass methods rather than scopes in create_connection method * chore: add extra tests * fix: use browser router in http mode * fix: update links to not use hash router * fix: add redirect from hash router url * fix: return nostrWalletConnectUrl in nwc connection success event and message * feat: publish nwa event * chore: use nwc info event instead of nwa event * feat: create custom alby go detail page * chore: allow creating/editing apps with the same name * fix: convert budget from msats to sats (#1111) * chore: address NWA feedback * chore: address feedback - adjust button copy - make create_connection methods consistent with http deeplink flow - remove unused constant - add empty string check before adding lud16 tag - fix test * feat: add support for notification_types in create_connection method * fix: shorter button copy * fix: do not include lud16 tag in published info event * Feat: add lud16 to get_info response (#1128) feat: add lud16 to get_info response * chore: minor alby go screen improvements * fix: incorrect unlock password error message to create app with superuser access * chore: minor ui improvements on alby go detail page * chore: avoid duplicate app names by adding a suffix * chore: move scopes check to apps service, add new tests, DRY controller test setup * fix: scopes component full access scopes and isolated scope group check * fix: use supported capabilities for Alby Go * fix: return correct app name * chore: address minor comments --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
- Loading branch information
1 parent
1d5730a
commit 3e1d16d
Showing
49 changed files
with
1,856 additions
and
297 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package api | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/getAlby/hub/constants" | ||
"github.com/getAlby/hub/tests/mocks" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCreateApp_SuperuserScopeIncorrectPassword(t *testing.T) { | ||
cfg := mocks.NewMockConfig(t) | ||
cfg.On("CheckUnlockPassword", "").Return(false) | ||
theAPI := &api{svc: mocks.NewMockService(t), cfg: cfg} | ||
response, err := theAPI.CreateApp(&CreateAppRequest{ | ||
Scopes: []string{constants.SUPERUSER_SCOPE}, | ||
}) | ||
|
||
assert.Nil(t, response) | ||
require.Error(t, err) | ||
assert.Equal(t, "incorrect unlock password to create app with superuser permission", err.Error()) | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package tests | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/getAlby/hub/apps" | ||
"github.com/getAlby/hub/config" | ||
"github.com/getAlby/hub/constants" | ||
"github.com/getAlby/hub/tests" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestHandleCreateApp_NilScopes(t *testing.T) { | ||
// ctx := context.TODO() | ||
svc, err := tests.CreateTestService(t) | ||
require.NoError(t, err) | ||
defer svc.Remove() | ||
|
||
appsService := apps.NewAppsService(svc.DB, svc.EventPublisher, svc.Keys, svc.Cfg) | ||
app, secretKey, err := appsService.CreateApp("Test", "", 0, "monthly", nil, nil, false, nil) | ||
|
||
assert.Nil(t, app) | ||
assert.Equal(t, "", secretKey) | ||
require.Error(t, err) | ||
assert.Equal(t, "no scopes provided", err.Error()) | ||
} | ||
|
||
func TestHandleCreateApp_EmptyScopes(t *testing.T) { | ||
// ctx := context.TODO() | ||
svc, err := tests.CreateTestService(t) | ||
require.NoError(t, err) | ||
defer svc.Remove() | ||
|
||
appsService := apps.NewAppsService(svc.DB, svc.EventPublisher, svc.Keys, svc.Cfg) | ||
app, secretKey, err := appsService.CreateApp("Test", "", 0, "monthly", nil, []string{}, false, nil) | ||
|
||
assert.Nil(t, app) | ||
assert.Equal(t, "", secretKey) | ||
require.Error(t, err) | ||
assert.Equal(t, "no scopes provided", err.Error()) | ||
} | ||
|
||
func TestHandleCreateApp_IsolatedUnsupportedBackendType(t *testing.T) { | ||
// ctx := context.TODO() | ||
svc, err := tests.CreateTestService(t) | ||
require.NoError(t, err) | ||
defer svc.Remove() | ||
svc.Cfg.SetUpdate("BackendType", config.CashuBackendType, "") | ||
|
||
appsService := apps.NewAppsService(svc.DB, svc.EventPublisher, svc.Keys, svc.Cfg) | ||
app, secretKey, err := appsService.CreateApp("Test", "", 0, "monthly", nil, []string{constants.GET_INFO_SCOPE}, true, nil) | ||
|
||
assert.Nil(t, app) | ||
assert.Equal(t, "", secretKey) | ||
require.Error(t, err) | ||
assert.Equal(t, "sub-wallets are currently not supported on your node backend. Try LDK or LND", err.Error()) | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.