Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lakhansamani committed Apr 2, 2024
1 parent 67f866a commit 28b574c
Show file tree
Hide file tree
Showing 51 changed files with 275 additions and 143 deletions.
16 changes: 8 additions & 8 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"author": "Lakhan Samani",
"license": "ISC",
"dependencies": {
"@authorizerdev/authorizer-react": "^1.2.0",
"@authorizerdev/authorizer-react": "^1.3.1",
"@types/react": "^17.0.15",
"@types/react-dom": "^17.0.9",
"esbuild": "^0.12.17",
Expand Down
1 change: 0 additions & 1 deletion app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default function App() {
...window['__authorizer__'],
...urlProps,
};
console.log({ globalState });
return (
<div
style={{
Expand Down
18 changes: 9 additions & 9 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# yarn lockfile v1


"@authorizerdev/authorizer-js@^2.0.0-beta.3":
version "2.0.0-beta.3"
resolved "https://registry.npmjs.org/@authorizerdev/authorizer-js/-/authorizer-js-2.0.0-beta.3.tgz"
integrity sha512-cEzEVe7AewvOwOwoettiKRCq1e5Y33k9g8fJjqAoe3B/36iNN8wnZ5qgsPPZkqhv+Cvn6huj+YWtRimfVJ6d0w==
"@authorizerdev/authorizer-js@^2.0.2":
version "2.0.2"
resolved "https://registry.npmjs.org/@authorizerdev/authorizer-js/-/authorizer-js-2.0.2.tgz"
integrity sha512-YgCtpaBDGYGMUlINFsvGNJnBtbnFG2wo66xX2i6auop52oVmKimvLpzOx8306/YddCxWhg9FljyVMp88Mbnxyw==
dependencies:
cross-fetch "^3.1.5"

"@authorizerdev/authorizer-react@^1.2.0":
version "1.2.0"
resolved "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-1.2.0.tgz"
integrity sha512-MtunZgh30rzY9jSADVP1DRC4sOBC82zx/yhK8O/1ufOAi7vTDZwPjDHIMrG/xWPNUYTCeFPEKpZlKyB+TH/M1w==
"@authorizerdev/authorizer-react@^1.3.1":
version "1.3.1"
resolved "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-1.3.1.tgz"
integrity sha512-X7vQMr5jtZ28z+YZOt5ISB3lOYXNszpLpWw4S6VNs7TLAd5/ZP2kPaSdDbUgIvQFyYy51DHQeGygOu3G1n0Mdw==
dependencies:
"@authorizerdev/authorizer-js" "^2.0.0-beta.3"
"@authorizerdev/authorizer-js" "^2.0.2"
validator "^13.11.0"

"@babel/code-frame@^7.22.13":
Expand Down
15 changes: 14 additions & 1 deletion dashboard/src/components/EnvComponents/Features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Features = ({ variables, setVariables }: any) => {
</Flex>
<Flex>
<Flex w="100%" justifyContent="start" alignItems="center">
<Text fontSize="sm">Basic Authentication:</Text>
<Text fontSize="sm">Email Basic Authentication:</Text>
</Flex>
<Flex justifyContent="start">
<InputField
Expand All @@ -64,6 +64,19 @@ const Features = ({ variables, setVariables }: any) => {
/>
</Flex>
</Flex>
<Flex>
<Flex w="100%" justifyContent="start" alignItems="center">
<Text fontSize="sm">Mobile Basic Authentication:</Text>
</Flex>
<Flex justifyContent="start">
<InputField
variables={variables}
setVariables={setVariables}
inputType={SwitchInputType.DISABLE_MOBILE_BASIC_AUTHENTICATION}
hasReversedValue
/>
</Flex>
</Flex>
<Flex>
<Flex w="100%" justifyContent="start" alignItems="center">
<Text fontSize="sm">Sign Up:</Text>
Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const SwitchInputType = {
DISABLE_MAGIC_LINK_LOGIN: 'DISABLE_MAGIC_LINK_LOGIN',
DISABLE_EMAIL_VERIFICATION: 'DISABLE_EMAIL_VERIFICATION',
DISABLE_BASIC_AUTHENTICATION: 'DISABLE_BASIC_AUTHENTICATION',
DISABLE_MOBILE_BASIC_AUTHENTICATION: 'DISABLE_MOBILE_BASIC_AUTHENTICATION',
DISABLE_SIGN_UP: 'DISABLE_SIGN_UP',
DISABLE_REDIS_FOR_ENV: 'DISABLE_REDIS_FOR_ENV',
DISABLE_STRONG_PASSWORD: 'DISABLE_STRONG_PASSWORD',
Expand Down Expand Up @@ -167,6 +168,7 @@ export interface envVarTypes {
DISABLE_MAGIC_LINK_LOGIN: boolean;
DISABLE_EMAIL_VERIFICATION: boolean;
DISABLE_BASIC_AUTHENTICATION: boolean;
DISABLE_MOBILE_BASIC_AUTHENTICATION: boolean;
DISABLE_SIGN_UP: boolean;
DISABLE_STRONG_PASSWORD: boolean;
OLD_ADMIN_SECRET: string;
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/graphql/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const EnvVariablesQuery = `
DISABLE_MAGIC_LINK_LOGIN
DISABLE_EMAIL_VERIFICATION
DISABLE_BASIC_AUTHENTICATION
DISABLE_MOBILE_BASIC_AUTHENTICATION
DISABLE_SIGN_UP
DISABLE_STRONG_PASSWORD
DISABLE_REDIS_FOR_ENV
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/pages/Environment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const Environment = () => {
DISABLE_MAGIC_LINK_LOGIN: false,
DISABLE_EMAIL_VERIFICATION: false,
DISABLE_BASIC_AUTHENTICATION: false,
DISABLE_MOBILE_BASIC_AUTHENTICATION: false,
DISABLE_SIGN_UP: false,
DISABLE_STRONG_PASSWORD: false,
OLD_ADMIN_SECRET: '',
Expand Down
8 changes: 4 additions & 4 deletions server/db/providers/arangodb/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (p *provider) AddAuthenticator(ctx context.Context, authenticators *models.
authenticatorsCollection, _ := p.db.Collection(ctx, models.Collections.Authenticators)
meta, err := authenticatorsCollection.CreateDocument(arangoDriver.WithOverwrite(ctx), authenticators)
if err != nil {
return authenticators, err
return nil, err
}
authenticators.Key = meta.Key
authenticators.ID = meta.ID.String()
Expand All @@ -42,7 +42,7 @@ func (p *provider) UpdateAuthenticator(ctx context.Context, authenticators *mode
collection, _ := p.db.Collection(ctx, models.Collections.Authenticators)
meta, err := collection.UpdateDocument(ctx, authenticators.Key, authenticators)
if err != nil {
return authenticators, err
return nil, err
}

authenticators.Key = meta.Key
Expand All @@ -59,7 +59,7 @@ func (p *provider) GetAuthenticatorDetailsByUserId(ctx context.Context, userId s
}
cursor, err := p.db.Query(ctx, query, bindVars)
if err != nil {
return authenticators, err
return nil, err
}
defer cursor.Close()
for {
Expand All @@ -71,7 +71,7 @@ func (p *provider) GetAuthenticatorDetailsByUserId(ctx context.Context, userId s
}
_, err := cursor.ReadDocument(ctx, &authenticators)
if err != nil {
return authenticators, err
return nil, err
}
}
return authenticators, nil
Expand Down
8 changes: 4 additions & 4 deletions server/db/providers/arangodb/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (p *provider) AddEnv(ctx context.Context, env *models.Env) (*models.Env, er
configCollection, _ := p.db.Collection(ctx, models.Collections.Env)
meta, err := configCollection.CreateDocument(arangoDriver.WithOverwrite(ctx), env)
if err != nil {
return env, err
return nil, err
}
env.Key = meta.Key
env.ID = meta.ID.String()
Expand All @@ -36,7 +36,7 @@ func (p *provider) UpdateEnv(ctx context.Context, env *models.Env) (*models.Env,
collection, _ := p.db.Collection(ctx, models.Collections.Env)
meta, err := collection.UpdateDocument(ctx, env.Key, env)
if err != nil {
return env, err
return nil, err
}

env.Key = meta.Key
Expand All @@ -50,7 +50,7 @@ func (p *provider) GetEnv(ctx context.Context) (*models.Env, error) {
query := fmt.Sprintf("FOR d in %s RETURN d", models.Collections.Env)
cursor, err := p.db.Query(ctx, query, nil)
if err != nil {
return env, err
return nil, err
}
defer cursor.Close()
for {
Expand All @@ -62,7 +62,7 @@ func (p *provider) GetEnv(ctx context.Context) (*models.Env, error) {
}
_, err := cursor.ReadDocument(ctx, &env)
if err != nil {
return env, err
return nil, err
}
}

Expand Down
18 changes: 9 additions & 9 deletions server/db/providers/arangodb/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (p *provider) AddUser(ctx context.Context, user *models.User) (*models.User
if user.Roles == "" {
defaultRoles, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyDefaultRoles)
if err != nil {
return user, err
return nil, err
}
user.Roles = defaultRoles
}
Expand All @@ -47,7 +47,7 @@ func (p *provider) AddUser(ctx context.Context, user *models.User) (*models.User
userCollection, _ := p.db.Collection(ctx, models.Collections.User)
meta, err := userCollection.CreateDocument(arangoDriver.WithOverwrite(ctx), user)
if err != nil {
return user, err
return nil, err
}
user.Key = meta.Key
user.ID = meta.ID.String()
Expand All @@ -62,7 +62,7 @@ func (p *provider) UpdateUser(ctx context.Context, user *models.User) (*models.U
collection, _ := p.db.Collection(ctx, models.Collections.User)
meta, err := collection.UpdateDocument(ctx, user.Key, user)
if err != nil {
return user, err
return nil, err
}

user.Key = meta.Key
Expand Down Expand Up @@ -129,19 +129,19 @@ func (p *provider) GetUserByEmail(ctx context.Context, email string) (*models.Us
}
cursor, err := p.db.Query(ctx, query, bindVars)
if err != nil {
return user, err
return nil, err
}
defer cursor.Close()
for {
if !cursor.HasMore() {
if user == nil {
return user, fmt.Errorf("user not found")
return nil, fmt.Errorf("user not found")
}
break
}
_, err := cursor.ReadDocument(ctx, &user)
if err != nil {
return user, err
return nil, err
}
}
return user, nil
Expand All @@ -156,19 +156,19 @@ func (p *provider) GetUserByID(ctx context.Context, id string) (*models.User, er
}
cursor, err := p.db.Query(ctx, query, bindVars)
if err != nil {
return user, err
return nil, err
}
defer cursor.Close()
for {
if !cursor.HasMore() {
if user == nil {
return user, fmt.Errorf("user not found")
return nil, fmt.Errorf("user not found")
}
break
}
_, err := cursor.ReadDocument(ctx, &user)
if err != nil {
return user, err
return nil, err
}
}
return user, nil
Expand Down
10 changes: 5 additions & 5 deletions server/db/providers/arangodb/verification_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (p *provider) AddVerificationRequest(ctx context.Context, verificationReque
verificationRequestRequestCollection, _ := p.db.Collection(ctx, models.Collections.VerificationRequest)
meta, err := verificationRequestRequestCollection.CreateDocument(ctx, verificationRequest)
if err != nil {
return verificationRequest, err
return nil, err
}
verificationRequest.Key = meta.Key
verificationRequest.ID = meta.ID.String()
Expand All @@ -38,7 +38,7 @@ func (p *provider) GetVerificationRequestByToken(ctx context.Context, token stri
}
cursor, err := p.db.Query(ctx, query, bindVars)
if err != nil {
return verificationRequest, err
return nil, err
}
defer cursor.Close()
for {
Expand All @@ -50,7 +50,7 @@ func (p *provider) GetVerificationRequestByToken(ctx context.Context, token stri
}
_, err := cursor.ReadDocument(ctx, &verificationRequest)
if err != nil {
return verificationRequest, err
return nil, err
}
}
return verificationRequest, nil
Expand All @@ -66,7 +66,7 @@ func (p *provider) GetVerificationRequestByEmail(ctx context.Context, email stri
}
cursor, err := p.db.Query(ctx, query, bindVars)
if err != nil {
return verificationRequest, err
return nil, err
}
defer cursor.Close()
for {
Expand All @@ -78,7 +78,7 @@ func (p *provider) GetVerificationRequestByEmail(ctx context.Context, email stri
}
_, err := cursor.ReadDocument(ctx, &verificationRequest)
if err != nil {
return verificationRequest, err
return nil, err
}
}
return verificationRequest, nil
Expand Down
12 changes: 6 additions & 6 deletions server/db/providers/cassandradb/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (p *provider) AddAuthenticator(ctx context.Context, authenticators *models.

bytes, err := json.Marshal(authenticators)
if err != nil {
return authenticators, err
return nil, err
}

// use decoder instead of json.Unmarshall, because it converts int64 -> float64 after unmarshalling
Expand All @@ -38,7 +38,7 @@ func (p *provider) AddAuthenticator(ctx context.Context, authenticators *models.
authenticatorsMap := map[string]interface{}{}
err = decoder.Decode(&authenticatorsMap)
if err != nil {
return authenticators, err
return nil, err
}

fields := "("
Expand Down Expand Up @@ -66,7 +66,7 @@ func (p *provider) AddAuthenticator(ctx context.Context, authenticators *models.
query := fmt.Sprintf("INSERT INTO %s %s VALUES %s IF NOT EXISTS", KeySpace+"."+models.Collections.Authenticators, fields, values)
err = p.db.Query(query).Exec()
if err != nil {
return authenticators, err
return nil, err
}

return authenticators, nil
Expand All @@ -77,15 +77,15 @@ func (p *provider) UpdateAuthenticator(ctx context.Context, authenticators *mode

bytes, err := json.Marshal(authenticators)
if err != nil {
return authenticators, err
return nil, err
}
// use decoder instead of json.Unmarshall, because it converts int64 -> float64 after unmarshalling
decoder := json.NewDecoder(strings.NewReader(string(bytes)))
decoder.UseNumber()
authenticatorsMap := map[string]interface{}{}
err = decoder.Decode(&authenticatorsMap)
if err != nil {
return authenticators, err
return nil, err
}

updateFields := ""
Expand Down Expand Up @@ -116,7 +116,7 @@ func (p *provider) UpdateAuthenticator(ctx context.Context, authenticators *mode
query := fmt.Sprintf("UPDATE %s SET %s WHERE id = '%s'", KeySpace+"."+models.Collections.Authenticators, updateFields, authenticators.ID)
err = p.db.Query(query).Exec()
if err != nil {
return authenticators, err
return nil, err
}

return authenticators, nil
Expand Down
Loading

0 comments on commit 28b574c

Please sign in to comment.