-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently only a very initial changes to allow smoke test for the application from the local workstation for the developer (by extension later into the pipeline could be added too). This same infrastructure could be reused for integration tests which will test the wrong scenarios for the different endpoints. Be aware the current SetupTest method is a copy from the cmd/service/main.go code; this is starting exactly the same as the service (and will need the same external dependencies: database, [kafka? future maybe], [s3 storage, not our use case]). Maybe chop and move to `internal/infrastructure/helper.go` so we reuse from `cmd/service/main.go` and from `internal/test/smoke/main.go` files. The intention is that calling: `make compose-clean clean build compose-up test-smoke` we would run the smoke tests. --- A similar approach reusing all the helpers could works for integration tests: `make compose-clean clean build compose-up test-integration` we would run the integration tests. --- build: update make rules This change execute separatly tests and smoke tests; the unit tests can be run in parallel. However the smoke tests, currently cannot run in parallel because the service is not being configured with different ports, and that evoke the sockets to fail on setting up. Said that, it is not impossible to achieve that, as we can choose random ports for service and metrics; making that, we would only need to run the tests avoiding data overlaping. To achieve no data overlaping the easier way is using a different org_id for each test; in that way the database should not overlap. To implement this, I suggest to implement a generator, which will be just a counter, starting in a random start sequence. Once both of the above two features are added to the smoke tests, that will allow to run them in parallel with no collision. --- TODO - [x] Review current state could works for integration tests. - [x] Update docs/dev/TESTING.md file with step by step guide (two approaches). - [.] Implement more use cases. - [x] Create token. - [.] Register rhel-idm domain. - [ ] Read rhel-idm domain. - [ ] List rhel-idm domain. - [ ] Patch rhel-idm domain. - [ ] Update rhel-idm domain. - [ ] Delete rhel-idm domain. - [x] Refactor to reuse common components: integration tests, start/stop sequences. - [ ] Show coverage for smoke tests. - [.] Add API builder components. - [.] Add MODEL builder components. - [.] Fix situation when running in the pipeline. - [ ] Reorg the commit. Signed-off-by: Alejandro Visiedo <[email protected]>
- Loading branch information
Showing
22 changed files
with
1,798 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
logging: | ||
level: info # The normal level in production | ||
# level: trace # Will display the sql statements, usefult for development | ||
# level: debug | ||
# Set to false to get a json output for the log | ||
console: true | ||
|
||
web: | ||
port: 8000 | ||
|
||
database: | ||
host: localhost | ||
port: 5432 | ||
user: postgres | ||
password: postgres | ||
name: postgres | ||
|
||
kafka: | ||
auto: | ||
offset: | ||
reset: latest | ||
commit: | ||
interval: | ||
ms: 5000 | ||
bootstrap: | ||
servers: localhost:9092 | ||
group: | ||
id: idmsvc | ||
message: | ||
send: | ||
max: | ||
retries: 15 | ||
request: | ||
timeout: | ||
ms: 30000 | ||
required: | ||
acks: -1 | ||
retry: | ||
backoff: | ||
ms: 100 | ||
timeout: 10000 | ||
topics: | ||
- platform.idmsvc.introspect | ||
# sasl: | ||
# username: someusername | ||
# passowrd: somepassword | ||
# mechanism: somemechanism | ||
# protocol: someprotocol | ||
|
||
# cloudwatch: | ||
# region: | ||
# group: | ||
# stream: | ||
# key: | ||
# secret: | ||
# session: | ||
# options: | ||
# paged_rpm_inserts_limit: 100 | ||
metrics: | ||
path: "/metrics" | ||
port: 9000 | ||
|
||
clients: | ||
inventory: | ||
base_url: http://localhost:8010/api/inventory/v1 | ||
|
||
app: | ||
# Token expiration time in seconds | ||
# default: 2 hours | ||
token_expiration_seconds: 7200 | ||
# The pagination default limit for the first list request | ||
pagination_default_limit: 10 | ||
# The pagination max limit to avoid bigger values and long requests | ||
pagination_max_limit: 100 | ||
# Allow to inject a system identity for development propose | ||
accept_x_rh_fake_identity: false | ||
# Validate API requests and response against the openapi specification | ||
validate_api: true | ||
# main secret for various MAC and encryptions like domain registration | ||
# token and encrypted private JWKs. "random" generates an ephemeral secret. | ||
secret: random |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
"github.com/openlyinc/pointy" | ||
"github.com/podengo-project/idmsvc-backend/internal/api/public" | ||
builder_helper "github.com/podengo-project/idmsvc-backend/internal/test/builder/helper" | ||
) | ||
|
||
type Domain interface { | ||
Build() *public.Domain | ||
} | ||
|
||
type domain public.Domain | ||
|
||
func NewDomain(domainName string) Domain { | ||
domainID := uuid.New() | ||
return &domain{ | ||
DomainId: &domainID, | ||
AutoEnrollmentEnabled: builder_helper.GenRandPointyBool(), | ||
Description: pointy.String(builder_helper.GenLorempIpsum()), | ||
DomainName: domainName, | ||
DomainType: public.RhelIdm, | ||
Title: pointy.String(domainName), | ||
RhelIdm: NewRhelIdmDomain(domainName).Build(), | ||
} | ||
} | ||
|
||
func (b *domain) Build() *public.Domain { | ||
return (*public.Domain)(b) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package api | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/podengo-project/idmsvc-backend/internal/api/public" | ||
) | ||
|
||
type RhelIdmDomain interface { | ||
Build() *public.DomainIpa | ||
AddRealmDomain(value string) RhelIdmDomain | ||
AddCaCert(value public.Certificate) RhelIdmDomain | ||
} | ||
|
||
type rhelIdmDomain public.DomainIpa | ||
|
||
func NewRhelIdmDomain(domainName string) RhelIdmDomain { | ||
data := &rhelIdmDomain{ | ||
RealmName: strings.ToUpper(domainName), | ||
RealmDomains: []string{domainName}, | ||
CaCerts: []public.Certificate{}, | ||
Locations: []public.Location{}, | ||
Servers: []public.DomainIpaServer{}, | ||
AutomountLocations: &[]string{}, | ||
} | ||
return data | ||
} | ||
|
||
func (b *rhelIdmDomain) Build() *public.DomainIpa { | ||
return (*public.DomainIpa)(b) | ||
} | ||
|
||
func (b *rhelIdmDomain) AddRealmDomain(value string) RhelIdmDomain { | ||
b.RealmDomains = append(b.RealmDomains, value) | ||
return b | ||
} | ||
|
||
func (b *rhelIdmDomain) AddCaCert(value public.Certificate) RhelIdmDomain { | ||
b.CaCerts = append(b.CaCerts, value) | ||
return b | ||
} | ||
|
||
func (b *rhelIdmDomain) AddLocation(value public.Location) RhelIdmDomain { | ||
b.Locations = append(b.Locations, value) | ||
return b | ||
} | ||
|
||
func (b *rhelIdmDomain) AddServer(value public.DomainIpaServer) RhelIdmDomain { | ||
b.Servers = append(b.Servers, value) | ||
return b | ||
} | ||
|
||
func (b *rhelIdmDomain) AutomountLocation(value string) RhelIdmDomain { | ||
if b.AutomountLocations == nil { | ||
panic("'AutomountLocations' is nil") | ||
} | ||
*b.AutomountLocations = append(*b.AutomountLocations, value) | ||
return b | ||
} |
Oops, something went wrong.