Skip to content

Commit

Permalink
Merge pull request #413 from ARGOeu/devel
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
themiszamani authored Jun 6, 2022
2 parents 36de75c + 8ac8aa3 commit 06bf367
Show file tree
Hide file tree
Showing 57 changed files with 19,481 additions and 9,906 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
argo-messaging
_workspace/
.idea
.vscode/
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ pipeline {
}
}
stage ('Deploy Docs') {
when {
branch 'devel'
}
agent {
docker {
image 'node:buster'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ resides in two possible locations:
- `verify_push_server` - (true|false) mutual TLS for the push server
- `push_worker_token` - token for the active push worker user
- `log_facilities` - ["syslog", "console"]
- `auth_option`: (`key`|`header`|`both`), where should the service look for the access token.

- `auth_option` - (`key`|`header`|`both`), where should the service look for the access token.
- `proxy_hostname` - The FQDN of any proxy or load balancer that might serve request in place of the AMS

#### Build & Run the service

Expand Down
4 changes: 3 additions & 1 deletion argo-messaging.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Name: argo-messaging
Summary: ARGO Messaging API for broker network
Version: 1.1.0
Version: 1.2.0
Release: 1%{?dist}
License: ASL 2.0
Buildroot: %{_tmppath}/%{name}-buildroot
Expand Down Expand Up @@ -63,6 +63,8 @@ go clean
%attr(0644,root,root) /usr/lib/systemd/system/argo-messaging.service

%changelog
* Thu May 19 2022 Agelos Tsalapatis <[email protected]> 1.2.0-1%{?dist}
- AMS release 1.2.0
* Mon Nov 8 2021 Agelos Tsalapatis <[email protected]> 1.1.0-1%{?dist}
- AMS release 1.1.0
* Wed Mar 31 2021 Agelos Tsalapatis <[email protected]> 1.0.8-1%{?dist}
Expand Down
2 changes: 1 addition & 1 deletion auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ func (suite *AuthTestSuite) TestUpdateUserRegistration() {

store := stores.NewMockStore("", "")
m := time.Date(2020, 8, 5, 11, 33, 45, 0, time.UTC)
e1 := UpdateUserRegistration("ur-uuid1", AcceptedRegistrationStatus, "uuid1", m, store)
e1 := UpdateUserRegistration("ur-uuid1", AcceptedRegistrationStatus, "dc", "uuid1", m, store)
ur1, _ := FindUserRegistration("ur-uuid1", "accepted", store)
expur1 := UserRegistration{
UUID: "ur-uuid1",
Expand Down
13 changes: 10 additions & 3 deletions auth/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ type UserRegistration struct {
Description string `json:"description"`
Email string `json:"email"`
Status string `json:"status"`
ActivationToken string `json:"activation_token"`
DeclineComment string `json:"decline_comment,omitempty"`
ActivationToken string `json:"activation_token,omitempty"`
RegisteredAt string `json:"registered_at"`
ModifiedBy string `json:"modified_by,omitempty"`
ModifiedAt string `json:"modified_at,omitempty"`
Expand Down Expand Up @@ -170,6 +171,7 @@ func FindUserRegistration(regUUID, status string, str stores.Store) (UserRegistr
Email: q[0].Email,
ActivationToken: q[0].ActivationToken,
Status: q[0].Status,
DeclineComment: q[0].DeclineComment,
Organization: q[0].Organization,
Description: q[0].Description,
RegisteredAt: q[0].RegisteredAt,
Expand Down Expand Up @@ -210,6 +212,7 @@ func FindUserRegistrations(status, activationToken, name, email, org string, str
Email: ur.Email,
ActivationToken: ur.ActivationToken,
Status: ur.Status,
DeclineComment: ur.DeclineComment,
Organization: ur.Organization,
Description: ur.Description,
RegisteredAt: ur.RegisteredAt,
Expand All @@ -223,8 +226,12 @@ func FindUserRegistrations(status, activationToken, name, email, org string, str
return urList, nil
}

func UpdateUserRegistration(regUUID, status, modifiedBy string, modifiedAt time.Time, refStr stores.Store) error {
return refStr.UpdateRegistration(regUUID, status, modifiedBy, modifiedAt.Format("2006-01-02T15:04:05Z"))
func UpdateUserRegistration(regUUID, status, declineComment, modifiedBy string, modifiedAt time.Time, refStr stores.Store) error {
// only accept decline comment with the decline status action
if status != DeclinedRegistrationStatus {
declineComment = ""
}
return refStr.UpdateRegistration(regUUID, status, declineComment, modifiedBy, modifiedAt.UTC().Format("2006-01-02T15:04:05Z"))
}

// NewUser accepts parameters and creates a new user
Expand Down
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"verify_push_server": true,
"push_worker_token": "8c8cbaeba3e1317c18cd5c03f3b1f596c23f922a",
"log_facilities": ["console"],
"auth_option": "both"
"auth_option": "both",
"proxy_hostname": "lb.ams.gr"
}
35 changes: 33 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ type APICfg struct {
ResAuth bool
ServiceToken string
LogLevel string
PushEnabled bool
// Proxy Hostname represents the FQDN of the a potential proxy/load balancer that might be
// serving requests in front of the ams instance
ProxyHostname string

PushEnabled bool
// Whether or not it should communicate over tls with the push server
PushTlsEnabled bool
// Push server endpoint
Expand Down Expand Up @@ -442,6 +446,14 @@ func (cfg *APICfg) LoadTest() {
},
).Info("Parameter Loaded - service_token")

// proxy hostname
cfg.ProxyHostname = viper.GetString("proxy_hostname")
log.WithFields(
log.Fields{
"type": "service_log",
},
).Infof("Parameter Loaded - proxy_hostname: %v", cfg.ProxyHostname)

// push enabled true or false
cfg.PushEnabled = viper.GetBool("push_enabled")
log.WithFields(
Expand Down Expand Up @@ -534,6 +546,9 @@ func (cfg *APICfg) Load() {
pflag.String("service-key", "", "service token definition for immediate full api access")
viper.BindPFlag("service_key", pflag.Lookup("service-key"))

pflag.String("proxy-hostname", "", "hostname in case ams is installed behind a proxy/load balancer")
viper.BindPFlag("proxy_hostname", pflag.Lookup("proxy-hostname"))

pflag.String("push-enabled", "", "enable automatic handling of push subscriptions at start-up")
viper.BindPFlag("push_enabled", pflag.Lookup("push-enabled"))

Expand Down Expand Up @@ -691,6 +706,14 @@ func (cfg *APICfg) Load() {
},
).Info("Parameter Loaded - service_token")

// proxy hostname
cfg.ProxyHostname = viper.GetString("proxy_hostname")
log.WithFields(
log.Fields{
"type": "service_log",
},
).Infof("Parameter Loaded - proxy_hostname: %v", cfg.ProxyHostname)

// push enabled true or false
cfg.PushEnabled = viper.GetBool("push_enabled")
log.WithFields(
Expand Down Expand Up @@ -832,7 +855,15 @@ func (cfg *APICfg) LoadStrJSON(input string) {
log.Fields{
"type": "service_log",
},
).Info("Parameter Loaded - service_token:")
).Info("Parameter Loaded - service_token")

// proxy hostname
cfg.ProxyHostname = viper.GetString("proxy_hostname")
log.WithFields(
log.Fields{
"type": "service_log",
},
).Infof("Parameter Loaded - proxy_hostname: %v", cfg.ProxyHostname)

// push enabled true or false
cfg.PushEnabled = viper.GetBool("push_enabled")
Expand Down
3 changes: 2 additions & 1 deletion config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"verify_push_server": true,
"push_worker_token": "pw-token",
"log_facilities": [],
"auth_option": "header"
"auth_option": "header",
"proxy_hostname": "lb.ams.gr"
}
4 changes: 3 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func (suite *ConfigTestSuite) SetupTest() {
"verify_push_server": "true",
"push_worker_token": "pw-token",
"log_facilities": ["SYSLOG", "CONSOLE"],
"auth_option": "header"
"auth_option": "header",
"proxy_hostname": "lb.ams.gr"
}`
}

Expand Down Expand Up @@ -66,6 +67,7 @@ func (suite *ConfigTestSuite) TestLoadConfiguration() {
suite.Equal("pw-token", APIcfg2.PushWorkerToken)
suite.True(APIcfg2.VerifyPushServer)
suite.Equal(0, len(APIcfg2.LogFacilities))
suite.Equal("lb.ams.gr", APIcfg2.ProxyHostname)
}

func (suite *ConfigTestSuite) TestLoadStringJSON() {
Expand Down
94 changes: 94 additions & 0 deletions doc/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ paths:
description: UUID of the registration
required: true
type: string
- name: comment
in: body
description: Comment regarding the declining of the registration.
required: false
schema:
type: object
properties:
comment:
type: string
tags:
- Registrations
responses:
Expand Down Expand Up @@ -2023,6 +2032,7 @@ paths:
500:
$ref: "#/responses/500"


delete:
summary: Delete an existing topic in a project
description: |
Expand Down Expand Up @@ -2061,6 +2071,82 @@ paths:
500:
$ref: "#/responses/500"

/projects/{PROJECT}/topics/{TOPIC}:attachSchema:
post:
summary: Link the given schema to the topic
description: |
Links the given schema to the topic
parameters:
- $ref: '#/parameters/ApiKey'
- name: PROJECT
in: path
description: Name of the project
required: true
type: string
- name: TOPIC
in: path
description: Name of the topic
required: true
type: string
- name: Schema
in: body
description: The name of the schema to be linked with the topic.All published messages will be validated against the linked schema.
required: false
schema:
type: object
properties:
schema:
type: string
tags:
- Topics
responses:
200:
description: Empty response
400:
$ref: "#/responses/400"
401:
$ref: "#/responses/401"
403:
$ref: "#/responses/403"
404:
$ref: "#/responses/404"
500:
$ref: "#/responses/500"


/projects/{PROJECT}/topics/{TOPIC}:detachSchema:
post:
summary: Unlink the given schema from the topic
description: |
Uninks the given schema from the topic
parameters:
- $ref: '#/parameters/ApiKey'
- name: PROJECT
in: path
description: Name of the project
required: true
type: string
- name: TOPIC
in: path
description: Name of the topic
required: true
type: string
tags:
- Topics
responses:
200:
description: Empty response
400:
$ref: "#/responses/400"
401:
$ref: "#/responses/401"
403:
$ref: "#/responses/403"
404:
$ref: "#/responses/404"
500:
$ref: "#/responses/500"



/projects/{PROJECT}/topics/{TOPIC}:publish:
Expand Down Expand Up @@ -2219,6 +2305,8 @@ paths:
get:
summary: "List API Version information"
description: "List api version information such as release version, commit hash etc"
parameters:
- $ref: '#/parameters/ApiKey'
tags:
- Version
produces:
Expand Down Expand Up @@ -2875,4 +2963,10 @@ definitions:
os:
type: string
architecture:
type: string
release:
type: string
distro:
type: string
hostname:
type: string
13 changes: 11 additions & 2 deletions doc/v1/docs/api_registrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,21 @@ Success Response
Please refer to section [Errors](api_errors.md) to see all possible Errors
## [POST] Manage Registrations - Decline a User's Registration
This request declines a user's registration
This request declines a user's registration.
You can also provide a comment regarding
the decline reason of the registration.
### Request
```json
POST "/v1/registrations/{uuid}:decline"
```
### Post body:
```json
{
"comment": "comment"
}
```
### Example request
```bash
Expand All @@ -111,7 +120,7 @@ curl -X POST -H "Content-Type: application/json"
```
### Responses
If successful, the response contains the newly created user
If successful, the response contains nothing
Success Response
`200 OK`
Expand Down
Loading

0 comments on commit 06bf367

Please sign in to comment.