Skip to content

Commit

Permalink
Fix #591: Test mode
Browse files Browse the repository at this point in the history
Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed Dec 4, 2023
1 parent f87997c commit 82ee9a5
Show file tree
Hide file tree
Showing 8 changed files with 366 additions and 344 deletions.
10 changes: 8 additions & 2 deletions internal/cmd/start_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func StartApiCmdHandler(cmd *cobra.Command, args []string) {
}

// Load the policy into the enforcer.
_, err = authEnforcer.AddPolicies(rbac.GetRbacPolicies())
_, err = authEnforcer.AddPolicies(rbac.GetRbacPolicies(loadedConfig.TestMode))
if err != nil {
panic(err)
}
Expand All @@ -95,7 +95,13 @@ func StartApiCmdHandler(cmd *cobra.Command, args []string) {

// Router
router := mux.NewRouter()
v2HttpPaths.SetRoutes(router, authEnforcer)
if loadedConfig.TestMode {
router.StrictSlash(true)
v2HttpPaths.SetRoutes(router, authEnforcer, loadedConfig.TestMode)
} else {
subrouter := router.PathPrefix("/v2").Subrouter()
v2HttpPaths.SetRoutes(subrouter, authEnforcer, loadedConfig.TestMode)
}

// Start server and listen in port 80
log.Println("Listening port 80")
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type Configuration struct {
Password string
}
ApplicationMode string
TestMode bool
Organization Organization
User User
ApiSecretKey string
Expand Down
10 changes: 5 additions & 5 deletions internal/http_path/v2/audit_paths.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package http_path

const AuditListDataAgreementRecords = "/v2/audit/consent-records"
const AuditDataAgreementRecordRead = "/v2/audit/consent-record/{consentRecordId}"
const AuditListDataAgreements = "/v2/audit/data-agreements"
const AuditReadDataAgreement = "/v2/audit/data-agreement/{dataAgreementId}"
const AuditListDataAgreementRecords = "/audit/consent-records"
const AuditDataAgreementRecordRead = "/audit/consent-record/{consentRecordId}"
const AuditListDataAgreements = "/audit/data-agreements"
const AuditReadDataAgreement = "/audit/data-agreement/{dataAgreementId}"

// organization action logs
const AuditGetOrgLogs = "/v2/audit/admin/logs"
const AuditGetOrgLogs = "/audit/admin/logs"
96 changes: 48 additions & 48 deletions internal/http_path/v2/config_paths.go
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
package http_path

// Global policy configuration
const ConfigCreatePolicy = "/v2/config/policy"
const ConfigReadPolicy = "/v2/config/policy/{policyId}"
const ConfigUpdatePolicy = "/v2/config/policy/{policyId}"
const ConfigDeletePolicy = "/v2/config/policy/{policyId}"
const ConfigListPolicies = "/v2/config/policies"
const ConfigListPolicyRevisions = "/v2/config/policy/{policyId}/revisions"
const ConfigCreatePolicy = "/config/policy"
const ConfigReadPolicy = "/config/policy/{policyId}"
const ConfigUpdatePolicy = "/config/policy/{policyId}"
const ConfigDeletePolicy = "/config/policy/{policyId}"
const ConfigListPolicies = "/config/policies"
const ConfigListPolicyRevisions = "/config/policy/{policyId}/revisions"

// Data agreements
const ConfigCreateDataAgreement = "/v2/config/data-agreement"
const ConfigReadDataAgreement = "/v2/config/data-agreement/{dataAgreementId}"
const ConfigUpdateDataAgreement = "/v2/config/data-agreement/{dataAgreementId}"
const ConfigDeleteDataAgreement = "/v2/config/data-agreement/{dataAgreementId}"
const ConfigListDataAgreements = "/v2/config/data-agreements"
const ConfigListDataAgreementRevisions = "/v2/config/data-agreement/{dataAgreementId}/revisions"
const ConfigListDataAttributesForDataAgreement = "/v2/config/data-agreement/{dataAgreementId}/data-attributes"
const ConfigCreateDataAgreement = "/config/data-agreement"
const ConfigReadDataAgreement = "/config/data-agreement/{dataAgreementId}"
const ConfigUpdateDataAgreement = "/config/data-agreement/{dataAgreementId}"
const ConfigDeleteDataAgreement = "/config/data-agreement/{dataAgreementId}"
const ConfigListDataAgreements = "/config/data-agreements"
const ConfigListDataAgreementRevisions = "/config/data-agreement/{dataAgreementId}/revisions"
const ConfigListDataAttributesForDataAgreement = "/config/data-agreement/{dataAgreementId}/data-attributes"

const ReadDataAgreementRevision = "/v2/config/data-agreement/{dataAgreementId}/revision/{revisionId}"
const ReadDataAgreementRevision = "/config/data-agreement/{dataAgreementId}/revision/{revisionId}"

// Data attributes
const ConfigReadDataAttribute = "/v2/config/data-agreements/data-attribute/{dataAttributeId}"
const ConfigCreateDataAttribute = "/v2/config/data-agreements/data-attribute"
const ConfigUpdateDataAttribute = "/v2/config/data-agreements/data-attribute/{dataAttributeId}"
const ConfigListDataAttributeRevisions = "/v2/config/data-agreements/data-attribute/{dataAttributeId}/revisions"
const ConfigDeleteDataAttribute = "/v2/config/data-agreements/data-attribute/{dataAttributeId}"
const ConfigListDataAttributes = "/v2/config/data-agreements/data-attributes"
const ConfigReadDataAttribute = "/config/data-agreements/data-attribute/{dataAttributeId}"
const ConfigCreateDataAttribute = "/config/data-agreements/data-attribute"
const ConfigUpdateDataAttribute = "/config/data-agreements/data-attribute/{dataAttributeId}"
const ConfigListDataAttributeRevisions = "/config/data-agreements/data-attribute/{dataAttributeId}/revisions"
const ConfigDeleteDataAttribute = "/config/data-agreements/data-attribute/{dataAttributeId}"
const ConfigListDataAttributes = "/config/data-agreements/data-attributes"

// Webhooks
const ConfigReadWebhook = "/v2/config/webhook/{webhookId}"
const ConfigCreateWebhook = "/v2/config/webhook"
const ConfigUpdateWebhook = "/v2/config/webhook/{webhookId}"
const ConfigDeleteWebhook = "/v2/config/webhook/{webhookId}"
const ConfigListWebhooks = "/v2/config/webhooks"
const ConfigPingWebhook = "/v2/config/webhook/{webhookId}/ping"
const ConfigListRecentWebhookDeliveries = "/v2/config/webhooks/{webhookId}/deliveries"
const ConfigReadRecentWebhookDelivery = "/v2/config/webhooks/{webhookId}/delivery/{deliveryId}"
const ConfigRedeliverWebhookPayloadByDeliveryID = "/v2/config/webhooks/{webhookId}/delivery/{deliveryId}/redeliver"
const ConfigListWebhookEventTypes = "/v2/config/webhooks/event-types"
const ConfigListWebhookPayloadContentTypes = "/v2/config/webhooks/payload/content-types"
const ConfigReadWebhook = "/config/webhook/{webhookId}"
const ConfigCreateWebhook = "/config/webhook"
const ConfigUpdateWebhook = "/config/webhook/{webhookId}"
const ConfigDeleteWebhook = "/config/webhook/{webhookId}"
const ConfigListWebhooks = "/config/webhooks"
const ConfigPingWebhook = "/config/webhook/{webhookId}/ping"
const ConfigListRecentWebhookDeliveries = "/config/webhooks/{webhookId}/deliveries"
const ConfigReadRecentWebhookDelivery = "/config/webhooks/{webhookId}/delivery/{deliveryId}"
const ConfigRedeliverWebhookPayloadByDeliveryID = "/config/webhooks/{webhookId}/delivery/{deliveryId}/redeliver"
const ConfigListWebhookEventTypes = "/config/webhooks/event-types"
const ConfigListWebhookPayloadContentTypes = "/config/webhooks/payload/content-types"

// Organisation identity provider related API(s)
const AddIdentityProvider = "/v2/config/idp/open-id"
const UpdateIdentityProvider = "/v2/config/idp/open-id/{idpId}"
const DeleteIdentityProvider = "/v2/config/idp/open-id/{idpId}"
const GetIdentityProvider = "/v2/config/idp/open-id/{idpId}"
const ConfigListIdentityProviders = "/v2/config/idp/open-ids"
const AddIdentityProvider = "/config/idp/open-id"
const UpdateIdentityProvider = "/config/idp/open-id/{idpId}"
const DeleteIdentityProvider = "/config/idp/open-id/{idpId}"
const GetIdentityProvider = "/config/idp/open-id/{idpId}"
const ConfigListIdentityProviders = "/config/idp/open-ids"

// Individuals
const ConfigCreateIndividual = "/v2/config/individual"
const ConfigReadIndividual = "/v2/config/individual/{individualId}"
const ConfigUpdateIndividual = "/v2/config/individual/{individualId}"
const ConfigDeleteIndividual = "/v2/config/individual/{individualId}"
const ConfigListIndividuals = "/v2/config/individuals"
const ConfigCreateIndividualsInBulk = "/v2/config/individual/upload"
const ConfigCreateIndividual = "/config/individual"
const ConfigReadIndividual = "/config/individual/{individualId}"
const ConfigUpdateIndividual = "/config/individual/{individualId}"
const ConfigDeleteIndividual = "/config/individual/{individualId}"
const ConfigListIndividuals = "/config/individuals"
const ConfigCreateIndividualsInBulk = "/config/individual/upload"

// Api key
const ConfigCreateApiKey = "/v2/config/admin/apikey"
const ConfigUpdateApiKey = "/v2/config/admin/apikey/{apiKeyId}"
const ConfigDeleteApiKey = "/v2/config/admin/apikey/{apiKeyId}"
const ConfigListApiKey = "/v2/config/admin/apikeys"
const ConfigCreateApiKey = "/config/admin/apikey"
const ConfigUpdateApiKey = "/config/admin/apikey/{apiKeyId}"
const ConfigDeleteApiKey = "/config/admin/apikey/{apiKeyId}"
const ConfigListApiKey = "/config/admin/apikeys"

const ConfigReadPrivacyDashboard = "/v2/config/privacy-dashboard"
const ConfigReadPrivacyDashboard = "/config/privacy-dashboard"

const ConfigPurgeOrgLogs = "/v2/config/logs/purge"
const ConfigPurgeOrgLogs = "/config/logs/purge"
44 changes: 22 additions & 22 deletions internal/http_path/v2/onboard_paths.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package http_path

// login
const LoginAdminUser = "/v2/onboard/admin/login"
const LoginUser = "/v2/onboard/individual/login"
const OnboardLogoutUser = "/v2/onboard/logout"
const LoginAdminUser = "/onboard/admin/login"
const LoginUser = "/onboard/individual/login"
const OnboardLogoutUser = "/onboard/logout"

const OnboardResetPassword = "/v2/onboard/password/reset"
const OnboardForgotPassword = "/v2/onboard/password/forgot"
const OnboardResetPassword = "/onboard/password/reset"
const OnboardForgotPassword = "/onboard/password/forgot"

// const ValidateUserEmail = "/v2/onboard/validate/email"
// const ValidatePhoneNumber = "/v2/onboard/validate/phone"
// const VerifyPhoneNumber = "/v2/onboard/verify/phone"
// const VerifyOtp = "/v2/onboard/verify/otp"
// const ValidateUserEmail = "/onboard/validate/email"
// const ValidatePhoneNumber = "/onboard/validate/phone"
// const VerifyPhoneNumber = "/onboard/verify/phone"
// const VerifyOtp = "/onboard/verify/otp"

const OnboardRefreshToken = "/v2/onboard/token/refresh"
const ExchangeAuthorizationCode = "/v2/onboard/token/exchange"
const OnboardRefreshToken = "/onboard/token/refresh"
const ExchangeAuthorizationCode = "/onboard/token/exchange"

const GetOrganizationByID = "/v2/onboard/organisation"
const UpdateOrganization = "/v2/onboard/organisation"
const UpdateOrganizationCoverImage = "/v2/onboard/organisation/coverimage"
const UpdateOrganizationLogoImage = "/v2/onboard/organisation/logoimage"
const GetOrganizationCoverImage = "/v2/onboard/organisation/coverimage"
const GetOrganizationLogoImage = "/v2/onboard/organisation/logoimage"
const GetOrganizationByID = "/onboard/organisation"
const UpdateOrganization = "/onboard/organisation"
const UpdateOrganizationCoverImage = "/onboard/organisation/coverimage"
const UpdateOrganizationLogoImage = "/onboard/organisation/logoimage"
const GetOrganizationCoverImage = "/onboard/organisation/coverimage"
const GetOrganizationLogoImage = "/onboard/organisation/logoimage"

const OnboardReadOrganisationAdmin = "/v2/onboard/admin"
const OnboardUpdateOrganisationAdmin = "/v2/onboard/admin"
const OnboardReadOrganisationAdminAvatar = "/v2/onboard/admin/avatarimage"
const OnboardUpdateOrganisationAdminAvatar = "/v2/onboard/admin/avatarimage"
const OnboardReadOrganisationAdmin = "/onboard/admin"
const OnboardUpdateOrganisationAdmin = "/onboard/admin"
const OnboardReadOrganisationAdminAvatar = "/onboard/admin/avatarimage"
const OnboardUpdateOrganisationAdminAvatar = "/onboard/admin/avatarimage"

const OnboardReadStatus = "/v2/onboard/status"
const OnboardReadStatus = "/onboard/status"
Loading

0 comments on commit 82ee9a5

Please sign in to comment.