Merge branch 'main' into yash/dashboard

This commit is contained in:
Lakhan Samani 2022-01-17 11:00:54 +05:30 committed by GitHub
commit 974622b9be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 121 additions and 132 deletions

View File

@ -60,181 +60,170 @@ Setup mongodb & arangodb using Docker
``` ```
docker run --name mongodb -d -p 27017:27017 mongo docker run --name mongodb -d -p 27017:27017 mongo
docker run --name arangodb -d -p 8529:8529 -e ARANGO_ROOT_PASSWORD=root arangodb/arangodb:3.8.4
// -e ARANGO_ROOT_PASSWORD=root
docker run --name arangodb -d -p 8529:8529 -e ARANGO_NO_AUTH=1 arangodb/arangodb:3.8.4
``` ```
> Note: If you are not making any changes in db schema / db operations, you can disable those db tests [here](https://github.com/authorizerdev/authorizer/blob/main/server/__test__/resolvers_test.go#L14) > Note: If you are not making any changes in db schema / db operations, you can disable those db tests [here](https://github.com/authorizerdev/authorizer/blob/main/server/__test__/resolvers_test.go#L14)
If you are adding new resolver, If you are adding new resolver,
1. create new resolver test file [here](https://github.com/authorizerdev/authorizer/tree/main/server/__test__) 1. create new resolver test file [here](https://github.com/authorizerdev/authorizer/tree/main/server/__test__)
Naming convention filename: `resolver_name_test.go` function name: `resolverNameTest(s TestSetup, t *testing.T)` Naming convention filename: `resolver_name_test.go` function name: `resolverNameTest(s TestSetup, t *testing.T)`
2. Add your tests [here](https://github.com/authorizerdev/authorizer/blob/main/server/__test__/resolvers_test.go#L38) 2. Add your tests [here](https://github.com/authorizerdev/authorizer/blob/main/server/__test__/resolvers_test.go#L38)
__Command to run tests:__ **Command to run tests:**
```sh ```sh
make test make test
``` ```
__Manual Testing:__ **Manual Testing:**
For manually testing using graphql playground, you can paste following queries and mutations in your playground and test it For manually testing using graphql playground, you can paste following queries and mutations in your playground and test it
```gql ```gql
mutation Signup { mutation Signup {
signup(params: { signup(
email: "lakhan@yopmail.com", params: {
password: "test", email: "lakhan@yopmail.com"
confirm_password: "test", password: "test"
given_name: "lakhan" confirm_password: "test"
}) { given_name: "lakhan"
message }
user { ) {
id message
family_name user {
given_name id
email family_name
email_verified given_name
} email
} email_verified
}
}
} }
mutation ResendEamil { mutation ResendEamil {
resend_verify_email(params: { resend_verify_email(
email: "lakhan@yopmail.com" params: { email: "lakhan@yopmail.com", identifier: "basic_auth_signup" }
identifier: "basic_auth_signup" ) {
}) { message
message }
}
} }
query GetVerifyRequests { query GetVerifyRequests {
_verification_requests { _verification_requests {
id id
token token
expires expires
identifier identifier
} }
} }
mutation VerifyEmail { mutation VerifyEmail {
verify_email(params: { verify_email(params: { token: "" }) {
token: "" access_token
}) { expires_at
access_token user {
expires_at id
user { email
id given_name
email email_verified
given_name }
email_verified }
}
}
} }
mutation Login { mutation Login {
login(params: { login(params: { email: "lakhan@yopmail.com", password: "test" }) {
email: "lakhan@yopmail.com", access_token
password: "test" expires_at
}) { user {
access_token id
expires_at family_name
user { given_name
id email
family_name }
given_name }
email
}
}
} }
query GetSession { query GetSession {
session { session {
access_token access_token
expires_at expires_at
user { user {
id id
given_name given_name
family_name family_name
email email
email_verified email_verified
signup_methods signup_methods
created_at created_at
updated_at updated_at
} }
} }
} }
mutation ForgotPassword { mutation ForgotPassword {
forgot_password(params: { forgot_password(params: { email: "lakhan@yopmail.com" }) {
email: "lakhan@yopmail.com" message
}) { }
message
}
} }
mutation ResetPassword { mutation ResetPassword {
reset_password(params: { reset_password(
token: "" params: { token: "", password: "test", confirm_password: "test" }
password: "test" ) {
confirm_password: "test" message
}) { }
message
}
} }
mutation UpdateProfile { mutation UpdateProfile {
update_profile(params: { update_profile(params: { family_name: "samani" }) {
family_name: "samani" message
}) { }
message
}
} }
query GetUsers { query GetUsers {
_users { _users {
id id
email email
email_verified email_verified
given_name given_name
family_name family_name
picture picture
signup_methods signup_methods
phone_number phone_number
} }
} }
mutation MagicLinkLogin { mutation MagicLinkLogin {
magic_link_login(params: { magic_link_login(params: { email: "test@yopmail.com" }) {
email: "test@yopmail.com" message
}) { }
message
}
} }
mutation Logout { mutation Logout {
logout { logout {
message message
} }
} }
mutation UpdateUser{ mutation UpdateUser {
_update_user(params: { _update_user(
id: "dafc9400-d603-4ade-997c-83fcd54bbd67", params: {
roles: ["user", "admin"] id: "dafc9400-d603-4ade-997c-83fcd54bbd67"
}) { roles: ["user", "admin"]
email }
roles ) {
} email
roles
}
} }
mutation DeleteUser { mutation DeleteUser {
_delete_user(params: { _delete_user(params: { email: "signup.test134523@yopmail.com" }) {
email: "signup.test134523@yopmail.com" message
}) { }
message
}
} }
``` ```

View File

@ -12,9 +12,9 @@ import (
func TestResolvers(t *testing.T) { func TestResolvers(t *testing.T) {
databases := map[string]string{ databases := map[string]string{
enum.Sqlite.String(): "../../data.db", enum.Sqlite.String(): "../../data.db",
// enum.Arangodb.String(): "http://root:root@localhost:8529", enum.Arangodb.String(): "http://localhost:8529",
// enum.Mongodb.String(): "mongodb://localhost:27017", enum.Mongodb.String(): "mongodb://localhost:27017",
} }
for dbType, dbURL := range databases { for dbType, dbURL := range databases {

View File

@ -9,12 +9,12 @@ import (
// version, // version,
func GetMetaInfo() model.Meta { func GetMetaInfo() model.Meta {
return model.Meta{ return model.Meta{
Version: constants.EnvData.VERSION, Version: constants.VERSION,
IsGoogleLoginEnabled: constants.EnvData.GOOGLE_CLIENT_ID != "" && constants.EnvData.GOOGLE_CLIENT_SECRET != "", IsGoogleLoginEnabled: constants.GOOGLE_CLIENT_ID != "" && constants.GOOGLE_CLIENT_SECRET != "",
IsGithubLoginEnabled: constants.EnvData.GITHUB_CLIENT_ID != "" && constants.EnvData.GOOGLE_CLIENT_SECRET != "", IsGithubLoginEnabled: constants.GITHUB_CLIENT_ID != "" && constants.GITHUB_CLIENT_SECRET != "",
IsFacebookLoginEnabled: constants.EnvData.FACEBOOK_CLIENT_ID != "" && constants.EnvData.FACEBOOK_CLIENT_SECRET != "", IsFacebookLoginEnabled: constants.FACEBOOK_CLIENT_ID != "" && constants.FACEBOOK_CLIENT_SECRET != "",
IsBasicAuthenticationEnabled: !constants.EnvData.DISABLE_BASIC_AUTHENTICATION, IsBasicAuthenticationEnabled: !constants.DISABLE_BASIC_AUTHENTICATION,
IsEmailVerificationEnabled: !constants.EnvData.DISABLE_EMAIL_VERIFICATION, IsEmailVerificationEnabled: !constants.DISABLE_EMAIL_VERIFICATION,
IsMagicLinkLoginEnabled: !constants.EnvData.DISABLE_MAGIC_LINK_LOGIN, IsMagicLinkLoginEnabled: !constants.DISABLE_MAGIC_LINK_LOGIN,
} }
} }