-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API for Retrieving All Documents (#755)
This commit introduces additional functionality required for the creation and retrieval of documents through REST API. Specifically, it adds the following enhancements: Authentication via Project Secret Key: Previously, authentication for API access was limited to user JWT tokens only. With this update, we have extended the authentication mechanism to also allow authentication using a SecretKey. This change provides more flexibility in how users and systems can authenticate and access our API. --------- Co-authored-by: Youngteac Hong <[email protected]>
- Loading branch information
1 parent
145d4f8
commit eaefcdc
Showing
9 changed files
with
177 additions
and
6 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
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 |
---|---|---|
|
@@ -70,6 +70,27 @@ func RunFindDocInfoTest( | |
}) | ||
} | ||
|
||
// RunFindProjectInfoBySecretKeyTest runs the FindProjectInfoBySecretKey test for the given db. | ||
func RunFindProjectInfoBySecretKeyTest( | ||
t *testing.T, | ||
db database.Database, | ||
) { | ||
t.Run("FindProjectInfoBySecretKey test", func(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
username := "[email protected]" | ||
password := "hashed-password" | ||
|
||
_, project, err := db.EnsureDefaultUserAndProject(ctx, username, password, clientDeactivateThreshold) | ||
assert.NoError(t, err) | ||
|
||
info2, err := db.FindProjectInfoBySecretKey(ctx, project.SecretKey) | ||
assert.NoError(t, err) | ||
|
||
assert.Equal(t, project.ID, info2.ID) | ||
}) | ||
} | ||
|
||
// RunFindProjectInfoByNameTest runs the FindProjectInfoByName test for the given db. | ||
func RunFindProjectInfoByNameTest( | ||
t *testing.T, | ||
|
@@ -272,6 +293,24 @@ func RunListUserInfosTest(t *testing.T, db database.Database) { | |
}) | ||
} | ||
|
||
// RunFindUserInfoByIDTest runs the FindUserInfoByID test for the given db. | ||
func RunFindUserInfoByIDTest(t *testing.T, db database.Database) { | ||
t.Run("RunFindUserInfoByID test", func(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
username := "findUserInfoTestAccount" | ||
password := "temporary-password" | ||
|
||
user, _, err := db.EnsureDefaultUserAndProject(ctx, username, password, clientDeactivateThreshold) | ||
assert.NoError(t, err) | ||
|
||
info1, err := db.FindUserInfoByID(ctx, user.ID) | ||
assert.NoError(t, err) | ||
|
||
assert.Equal(t, user.ID, info1.ID) | ||
}) | ||
} | ||
|
||
// RunActivateClientDeactivateClientTest runs the ActivateClient and DeactivateClient tests for the given db. | ||
func RunActivateClientDeactivateClientTest(t *testing.T, db database.Database, projectID types.ID) { | ||
t.Run("activate and find client test", func(t *testing.T) { | ||
|
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