├── bin └── .gitkeep ├── coverage └── .gitkeep ├── docker ├── build ├── Makefile ├── build.sh └── Dockerfile ├── VERSION ├── extras ├── basic_authentication │ ├── htpasswd │ ├── docker-compose.yml │ ├── nginx.conf │ └── README.md ├── registration_proxy │ ├── ngsi-go-config.json │ ├── mysql │ │ └── init.sql.gz │ ├── docker-compose.yml │ └── Dockerfile ├── apikey │ ├── mysql │ │ └── init.sql.gz │ └── docker-compose.yml ├── keyrock │ ├── mysql │ │ └── init.sql.gz │ └── docker-compose.yml ├── keycloak │ ├── postgres │ │ └── init.sql.gz │ ├── keycloak_oauth2.js │ ├── docker-compose.yml │ └── nginx.conf ├── tokenproxy │ ├── mysql │ │ └── init.sql.gz │ ├── docker-compose.yml │ └── Dockerfile ├── telefonica.security-stack │ └── mysql │ │ └── mysql_init.sql.gz └── queryproxy │ ├── ngsi-go-config.json │ ├── docker-compose.yml │ ├── nginx.conf │ └── Dockerfile ├── go.mod ├── ngsi-go-individual-cla.pdf ├── e2e ├── config │ ├── mysql-init.sql.gz │ ├── mongo-init.js │ └── custom_createsuperuser.py ├── script │ ├── docker-compose-up.sh │ └── rmi.sh ├── ngsi-test │ ├── ngsi-test-config.json │ ├── 9999_HALT │ └── main.go ├── cases │ ├── 3000_management │ │ └── 0501_license.test │ ├── 6000_time_series │ │ ├── 1000_comet │ │ │ ├── 0001_comet_version.test │ │ │ └── 0002_create_historical_data.test │ │ └── 2000_quantumleap │ │ │ ├── 0001_quantumleap_version.test │ │ │ ├── 0002_quantumleap_health.test │ │ │ └── 0010_hget_entities.test │ ├── 6200_perseo │ │ ├── 1000_perseo-core_version.test │ │ ├── 0002_perseo_version.test │ │ ├── 0001_perseo.test │ │ └── 0003_perseo_admin_log.test │ ├── 6300_cygnus │ │ ├── 0003_cygnus_version.test │ │ ├── 0001_cygnus.test │ │ └── 0060_metrics.test │ ├── 1000_common │ │ ├── 0002_ngsi_version.test │ │ └── 1001_stderr.test │ ├── 2000_convenience │ │ ├── 0201_cp_command.test │ │ └── 0401_man_command.test │ ├── 6100_iot_agent │ │ └── 0011_iota_version.test │ ├── 6500_keyrock │ │ ├── 1000_service_provider.test │ │ └── 0010_version.test │ ├── 6400_wirecloud │ │ ├── 0001_wirecloud.test │ │ └── 0002_wirecloud_version.test │ ├── 0000_prepare │ │ └── 0001_wait_for_services.test │ └── 4000_ngsi-v2 │ │ └── 9003_subs_only_uri.test ├── Makefile ├── run.sh ├── tokenproxy │ └── Dockerfile └── server │ ├── oauth │ └── Dockerfile │ ├── accumulator │ └── Dockerfile │ ├── csource │ └── Dockerfile │ └── atcontext │ └── Dockerfile ├── tools ├── package-lock.json ├── mdlint │ ├── package.json │ ├── Dockerfile │ └── Makefile └── textlint │ ├── package.json │ ├── Dockerfile │ └── Makefile ├── .remarkrc ├── .gitignore ├── .golangci.yml ├── .github ├── linters │ ├── .markdown-lint.yml │ └── .golangci.yml ├── workflows │ ├── docs.yml │ ├── lint.yml │ ├── e2e-test.yml │ ├── build.yml │ ├── unit-test.yml │ └── cla.yml └── pull_request_template.md ├── docs ├── files.md ├── convenience │ ├── man.md │ ├── health.md │ ├── rm.md │ ├── version.md │ ├── apis.md │ └── cp.md ├── build_source.md ├── keyrock │ └── providers.md ├── install.md ├── wirecloud │ └── preferences.md └── management │ └── token.md ├── SECURITY.md ├── signatures └── version1 │ └── cla.json ├── CONTRIBUTORS.md ├── autocomplete └── ngsi_bash_autocomplete ├── LICENSE ├── script ├── unit-test.sh ├── coverage.sh ├── release_buildx.sh ├── lint-docs.sh ├── e2e-test.sh ├── all-tests.sh ├── golangci-lint.sh └── lint-dockerfile.sh ├── internal ├── ngsilib │ ├── ziplib_test.go │ ├── syslog_lib_test.go │ ├── syslog_lib.go │ ├── ziplib.go │ ├── filepathlib_test.go │ ├── filepathlib.go │ ├── netlib_test.go │ ├── ioutillib_test.go │ ├── multipartlib_test.go │ ├── netlib.go │ ├── ioutillib.go │ ├── jsonlib.go │ └── jsonlib_test.go ├── cygnus │ └── helper_test.go ├── iotagent │ └── helper_test.go ├── keyrock │ └── helper_test.go ├── ngsicmd │ └── helper_test.go ├── perseo │ ├── helper_test.go │ └── flags.go ├── timeseries │ └── helper_test.go ├── wirecloud │ └── helper_test.go ├── helper │ ├── zip_file.go │ ├── syslog_lib.go │ ├── filepath_lib.go │ ├── zip_file_test.go │ ├── reader.go │ ├── syslog_lib_test.go │ ├── net_lib.go │ ├── multipart_lib.go │ ├── zip_lib.go │ ├── filepath_lib_test.go │ └── time_lib.go ├── convenience │ ├── documents_test.go │ ├── helper_test.go │ ├── debug_test.go │ ├── debug.go │ └── documents.go ├── ngsicli │ ├── args.go │ ├── token.go │ └── args_test.go └── management │ └── helper_test.go ├── cmd └── ngsi │ └── main.go └── roadmap.md /bin/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coverage/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docker/build: -------------------------------------------------------------------------------- 1 | ../build/ -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | VERSION=0.13.0-next 2 | -------------------------------------------------------------------------------- /extras/basic_authentication/htpasswd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /extras/registration_proxy/ngsi-go-config.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lets-fiware/ngsi-go 2 | 3 | go 1.19 4 | -------------------------------------------------------------------------------- /ngsi-go-individual-cla.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lets-fiware/ngsi-go/HEAD/ngsi-go-individual-cla.pdf -------------------------------------------------------------------------------- /e2e/config/mysql-init.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lets-fiware/ngsi-go/HEAD/e2e/config/mysql-init.sql.gz -------------------------------------------------------------------------------- /extras/apikey/mysql/init.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lets-fiware/ngsi-go/HEAD/extras/apikey/mysql/init.sql.gz -------------------------------------------------------------------------------- /extras/keyrock/mysql/init.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lets-fiware/ngsi-go/HEAD/extras/keyrock/mysql/init.sql.gz -------------------------------------------------------------------------------- /extras/keycloak/postgres/init.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lets-fiware/ngsi-go/HEAD/extras/keycloak/postgres/init.sql.gz -------------------------------------------------------------------------------- /extras/tokenproxy/mysql/init.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lets-fiware/ngsi-go/HEAD/extras/tokenproxy/mysql/init.sql.gz -------------------------------------------------------------------------------- /tools/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tools", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /extras/registration_proxy/mysql/init.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lets-fiware/ngsi-go/HEAD/extras/registration_proxy/mysql/init.sql.gz -------------------------------------------------------------------------------- /e2e/script/docker-compose-up.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ue 3 | echo "{"serviceMappings":[]}" > ./config/cygnus-name_mappings.conf 4 | docker compose up -d 5 | -------------------------------------------------------------------------------- /e2e/script/rmi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker image prune --filter label=stage=ngsi-builder -f 3 | docker image prune --filter label=stage=ngsi-runner -f 4 | -------------------------------------------------------------------------------- /tools/mdlint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "remark-cli": "^11.0.0", 4 | "remark-preset-lint-recommended": "^6.1.3" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /extras/telefonica.security-stack/mysql/mysql_init.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lets-fiware/ngsi-go/HEAD/extras/telefonica.security-stack/mysql/mysql_init.sql.gz -------------------------------------------------------------------------------- /.remarkrc: -------------------------------------------------------------------------------- 1 | { 2 | "settings": { 3 | "bullet": "-", 4 | "paddedTable": true 5 | }, 6 | "plugins": [ 7 | "remark-preset-lint-recommended" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | coverage.out 3 | coverage.lcov 4 | coverage.html 5 | bin/ 6 | build/ 7 | .vscode/ 8 | node_modules/ 9 | super-linter.log 10 | __debug_bin 11 | cygnus-name_mappings.conf 12 | *.wgt 13 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | enable: 3 | - errcheck 4 | - gofmt 5 | - gosimple 6 | - govet 7 | - ineffassign 8 | - misspell 9 | - staticcheck 10 | - unused 11 | disable-all: true 12 | -------------------------------------------------------------------------------- /.github/linters/.markdown-lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | MD007: 3 | indent: 4 4 | MD013: false 5 | MD024: false 6 | MD026: 7 | punctuation: ".," 8 | MD030: 9 | ol_multi: 3 10 | ol_single: 3 11 | ul_multi: 3 12 | ul_single: 3 13 | MD033: false 14 | MD034: false 15 | MD041: false 16 | -------------------------------------------------------------------------------- /docs/files.md: -------------------------------------------------------------------------------- 1 | # Files 2 | 3 | The NGSI Go command creates the following file. 4 | 5 | - ngsi-go-config.json 6 | - ngsi-go-config.json 7 | 8 | ## Linux 9 | 10 | ```console 11 | /home//.config/fiware 12 | ``` 13 | 14 | ## Mac 15 | 16 | ```console 17 | /Users//Library/Application Support/fiware 18 | ``` 19 | -------------------------------------------------------------------------------- /extras/keycloak/keycloak_oauth2.js: -------------------------------------------------------------------------------- 1 | function introspectAccessToken(req) { 2 | req.subrequest("/_request_introspection", 3 | function(reply) { 4 | req.return(reply.status == 200 5 | ? ((JSON.parse(reply.responseBody).active == true) ? 204 : 403) 6 | : 401); 7 | } 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Docs 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | lint-docs: 12 | name: Lint docs 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Git checkout 16 | uses: actions/checkout@v3 17 | 18 | - name: Run lint docs 19 | run: script/lint-docs.sh 20 | -------------------------------------------------------------------------------- /tools/textlint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "textlint": "^13.3.3", 4 | "textlint-filter-rule-allowlist": "^4.0.0", 5 | "textlint-filter-rule-comments": "^1.2.2", 6 | "textlint-rule-common-misspellings": "^1.0.1", 7 | "textlint-rule-no-dead-link": "^5.1.2", 8 | "textlint-rule-terminology": "^3.0.5", 9 | "textlint-rule-write-good": "^2.0.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | lint-gofiles: 12 | name: Lint go files 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: golangci-lint 17 | uses: golangci/golangci-lint-action@v3 18 | with: 19 | version: latest 20 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | -------- | ------------------ | 7 | | 0.12.0 | :white_check_mark: | 8 | | < 0.12.0 | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | Please contact us by email if you find any vulnerabilities related to NGSI Go. 13 | You can send an email to `ngsi-go-vulnerabilities@letsfiware.jp`. Do not use GitHub issues. 14 | -------------------------------------------------------------------------------- /.github/workflows/e2e-test.yml: -------------------------------------------------------------------------------- 1 | name: E2E tests 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | e2e-test: 12 | name: e2e test 13 | 14 | runs-on: ubuntu-latest 15 | 16 | env: 17 | TZ: Asia/Tokyo 18 | 19 | steps: 20 | - name: Checkout code 21 | uses: actions/checkout@v3 22 | 23 | - name: Run e2e test 24 | run: make e2e-test 25 | -------------------------------------------------------------------------------- /extras/basic_authentication/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | nginx: 5 | image: nginx:1.19.10 6 | ports: 7 | - 1026:1026 8 | volumes: 9 | - ./nginx.conf:/etc/nginx/nginx.conf:ro 10 | - ./htpasswd:/etc/nginx/.htpasswd:ro 11 | depends_on: 12 | - orion 13 | 14 | orion: 15 | image: fiware/orion:3.1.0 16 | depends_on: 17 | - mongo 18 | command: -dbhost mongo 19 | 20 | mongo: 21 | image: mongo:4.4 22 | command: --nojournal 23 | -------------------------------------------------------------------------------- /e2e/config/mongo-init.js: -------------------------------------------------------------------------------- 1 | db = connect("localhost:27017/orion"); 2 | db.createCollection("entities"); 3 | db.entities.createIndex({"_id.servicePath": 1, "_id.id": 1, "_id.type": 1}, {unique: true}); 4 | db.entities.createIndex({"_id.type": 1}); 5 | db.entities.createIndex({"_id.id": 1}); 6 | db = connect("localhost:27017/orionld"); 7 | db.createCollection("entities"); 8 | db.entities.createIndex({"_id.id": 1, "_id.type": 1}, {unique: true}); 9 | db.entities.createIndex({"_id.type": 1}); 10 | db.entities.createIndex({"_id.id": 1}); 11 | -------------------------------------------------------------------------------- /extras/queryproxy/ngsi-go-config.json: -------------------------------------------------------------------------------- 1 | {"contexts":{"etsi1.0":"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld","etsi1.3":"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld","etsi1.4":"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.4.jsonld","ld":"https://schema.lab.fiware.org/ld/context"},"servers":{"orion":{"serverType":"broker","serverHost":"http://orion:1026","ngsiType":"v2"}},"settings":{"usePreviousArgs":true,"syslog":"","stderr":"","logfile":"","loglevel":"","cachefile":"","host":"orion","tenant":"","scope":"","token":""},"version":"1"} 2 | -------------------------------------------------------------------------------- /extras/queryproxy/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | queryproxy: 5 | image: letsfiware/queryproxy:1.0 6 | build: ./ 7 | depends_on: 8 | - nginx 9 | 10 | nginx: 11 | image: nginx:1.19.10 12 | ports: 13 | - 1026:1026 14 | - 1030:1030 15 | volumes: 16 | - ./nginx.conf:/etc/nginx/nginx.conf:ro 17 | depends_on: 18 | - orion 19 | 20 | orion: 21 | image: fiware/orion:3.1.0 22 | depends_on: 23 | - mongo 24 | command: -dbhost mongo 25 | 26 | mongo: 27 | image: mongo:4.4 28 | command: --nojournal 29 | 30 | -------------------------------------------------------------------------------- /docs/convenience/man.md: -------------------------------------------------------------------------------- 1 | # man - Convenience command 2 | 3 | This command prints URLs of the documents related to the NGSI Go. 4 | 5 | ```console 6 | ngsi man 7 | ``` 8 | 9 | ### Options 10 | 11 | | Options | Description | 12 | | ------- | ------------------------- | 13 | | --help | show help (default: true) | 14 | 15 | ```text 16 | English: 17 | https://fiware-orion.readthedocs.io/ 18 | https://telefonicaid.github.io/fiware-orion/api/v2/stable/ 19 | https://ngsi-go.letsfiware.jp/ 20 | Japanese: 21 | https://fiware-orion.letsfiware.jp/ 22 | https://open-apis.letsfiware.jp/fiware-orion/api/v2/stable/ 23 | ``` 24 | -------------------------------------------------------------------------------- /extras/basic_authentication/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 1; 3 | 4 | events { 5 | worker_connections 1024; 6 | } 7 | 8 | http { 9 | include /etc/nginx/mime.types; 10 | 11 | server { 12 | listen 1026; 13 | 14 | location / { 15 | auth_basic "Restricted"; 16 | auth_basic_user_file /etc/nginx/.htpasswd; 17 | 18 | proxy_pass http://orion:1026; 19 | proxy_set_header Host $host; 20 | proxy_set_header X-Real-IP $remote_addr; 21 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /e2e/config/custom_createsuperuser.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth.management.commands import createsuperuser 2 | 3 | class Command(createsuperuser.Command): 4 | help = 'Create a superuser' 5 | 6 | def handle(self, *args, **options): 7 | options.setdefault('interactive', False) 8 | username = 'admin' 9 | email = 'admin@letsfiware.jp' 10 | password = '1234' 11 | database = options.get('database') 12 | 13 | user_data = { 14 | 'username': username, 15 | 'email': email, 16 | 'password': password, 17 | } 18 | 19 | self.UserModel._default_manager.db_manager(database).create_superuser(**user_data) 20 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | build-test: 12 | name: build test 13 | 14 | runs-on: ubuntu-latest 15 | 16 | env: 17 | TZ: Asia/Tokyo 18 | 19 | steps: 20 | - name: Install Go 21 | uses: actions/setup-go@v2 22 | with: 23 | go-version: 1.19 24 | 25 | - name: Checkout code 26 | uses: actions/checkout@v3 27 | 28 | - name: Checkout dependencies 29 | run: | 30 | go get github.com/x-motemen/gobump/cmd/gobump 31 | make devel-deps 32 | 33 | - name: Build NGSI Go 34 | run: make build 35 | -------------------------------------------------------------------------------- /e2e/ngsi-test/ngsi-test-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "valiables": { 3 | "orion": "http://orion:1026", 4 | "orion-ld": "http://orion-ld:1026", 5 | "comet": "http://comet:8666", 6 | "cygnus": "http://cygnus:5080", 7 | "quantumleap": "http://quantumleap:8668", 8 | "iota": "http://iot-agent:4041", 9 | "perseo": "http://perseo:9090", 10 | "perseo-core": "http://perseo-core:8080", 11 | "keyrock": "http://keyrock:3000", 12 | "pep-proxy": "http://pep-proxy:1026", 13 | "wirecloud": "http://wirecloud:8000", 14 | "accumulator": "http://accumulator:8000", 15 | "atcontext": "http://atcontext:8000", 16 | "csource": "http://csource:8000", 17 | "oauth": "http://oauth:8000" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /signatures/version1/cla.json: -------------------------------------------------------------------------------- 1 | { 2 | "signedContributors": [ 3 | { 4 | "name": "fisuda", 5 | "id": 31051904, 6 | "comment_id": 757105449, 7 | "created_at": "2021-01-09T06:31:53Z", 8 | "repoId": 312743711, 9 | "pullRequestNo": 44 10 | }, 11 | { 12 | "name": "modularTaco", 13 | "id": 37046961, 14 | "comment_id": 816532003, 15 | "created_at": "2021-04-09T08:54:21Z", 16 | "repoId": 312743711, 17 | "pullRequestNo": 120 18 | }, 19 | { 20 | "name": "Siedlerchr", 21 | "id": 320228, 22 | "comment_id": 856000917, 23 | "created_at": "2021-06-07T14:47:25Z", 24 | "repoId": 312743711, 25 | "pullRequestNo": 142 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /docs/build_source.md: -------------------------------------------------------------------------------- 1 | # Building from sources 2 | 3 | The building process of binaries are run in a Docker container. 4 | So that you do not need to prepare a Golang building environment. 5 | 6 | ```console 7 | git clone https://github.com/lets-fiware/ngsi-go.git 8 | cd ngsi-go 9 | make release 10 | ``` 11 | 12 | The binaries will be put in `build/` directory. 13 | 14 | ## Linux AMD64 15 | 16 | ```console 17 | make linux_amd64 18 | ``` 19 | 20 | ## Linux ARM64 21 | 22 | ```console 23 | make linux_arm64 24 | ``` 25 | 26 | ## Linux ARM 27 | 28 | ```console 29 | make linux_arm 30 | ``` 31 | 32 | ## Darwin AMD64 33 | 34 | ```console 35 | make darwin_amd64 36 | ``` 37 | 38 | ## Darwin ARM64 39 | 40 | ```console 41 | make darwin_arm64 42 | ``` 43 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # NGSI Go Contributors 2 | 3 | Thanks for the contribution! 4 | 5 | | Name | GitHub | Contribution | 6 | | -------------------- | ---------------------------------------------- | ------------------- | 7 | | Kazuhito Suda | [@fisuda](https://github.com/fisuda) | Project owner | 8 | | Jason Fox | [@jason-fox](https://github.com/jason-fox) | Documentation | 9 | | | [@modularTaco](https://github.com/modularTaco) | Documentation, code | 10 | | Fermín Galán Márquez | [@fgalan](https://github.com/fgalan) | Documentation | 11 | | Christoph | [@Siedlerchr](https://github.com/Siedlerchr) | Documentation | 12 | -------------------------------------------------------------------------------- /docs/keyrock/providers.md: -------------------------------------------------------------------------------- 1 | # providers - Keyrock command 2 | 3 | This command prints service providers for Keyrock 4 | 5 | ## Options 6 | 7 | | Options | Description | 8 | | ---------------------- | -------------------------------------- | 9 | | --host VALUE, -h VALUE | broker or server host VALUE (required) | 10 | | --pretty, -P | pretty format (default: false) | 11 | | --help | show help (default: true) | 12 | 13 | ### Examples 14 | 15 | #### Request: 16 | 17 | ```console 18 | ngsi providers --host keyrock --pretty 19 | ``` 20 | 21 | ```console 22 | { 23 | "information": { 24 | "total_users": 3, 25 | "total_organizations": 1, 26 | "total_applications": 5 27 | } 28 | } 29 | ``` 30 | -------------------------------------------------------------------------------- /autocomplete/ngsi_bash_autocomplete: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | PROG=ngsi 4 | brokers=`ngsi -B --syslog off --stderr err server list --all` 5 | 6 | _cli_bash_autocomplete() { 7 | if [[ "${COMP_WORDS[0]}" != "source" ]]; then 8 | local cur prev cword opts base 9 | _get_comp_words_by_ref -n : cur prev cword 10 | COMPREPLY=() 11 | cur="${COMP_WORDS[COMP_CWORD]}" 12 | if [ "${prev}" = "-h" -o "${prev}" = "--host" ]; then 13 | opts=${brokers} 14 | elif [[ "$cur" == "-"* ]]; then 15 | opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) 16 | else 17 | opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) 18 | fi 19 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 20 | return 0 21 | fi 22 | } 23 | 24 | complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG 25 | unset PROG 26 | -------------------------------------------------------------------------------- /docs/convenience/health.md: -------------------------------------------------------------------------------- 1 | # health - Convenience command 2 | 3 | This command prints the health status of FIWARE GE specified by the `--host` option. 4 | 5 | ```console 6 | ngsi health [options] 7 | ``` 8 | 9 | ## Options 10 | 11 | | Options | Description | 12 | | ------------------------------- | -------------------------------- | 13 | | --host value, -h value | specify host or alias (Required) | 14 | | --token value | specify oauth token | 15 | | --help | show help (default: false) | 16 | 17 | ### Example 18 | 19 | ```console 20 | ngsi health --host quantumleap 21 | ``` 22 | 23 | ```json 24 | { 25 | "status": "pass" 26 | } 27 | ``` 28 | 29 | ```console 30 | ngsi health --host quantumleap 31 | ``` 32 | 33 | ```json 34 | healthCheck004 error 503 SERVICE UNAVAILABLE { 35 | "details": { 36 | "crateDB": "cannot reach crate" 37 | }, 38 | "status": "fail" 39 | } 40 | ``` 41 | -------------------------------------------------------------------------------- /.github/workflows/unit-test.yml: -------------------------------------------------------------------------------- 1 | name: Unit Tests 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | unit-test: 12 | name: unit test 13 | 14 | runs-on: ubuntu-latest 15 | 16 | env: 17 | TZ: Asia/Tokyo 18 | 19 | steps: 20 | - name: Install Go 21 | uses: actions/setup-go@v2 22 | with: 23 | go-version: 1.19 24 | 25 | - name: Checkout code 26 | uses: actions/checkout@v3 27 | 28 | - name: Checkout dependencies 29 | run: | 30 | go get github.com/x-motemen/gobump/cmd/gobump 31 | make devel-deps 32 | 33 | - name: Test NGSI Go 34 | run: make unit-test 35 | 36 | - name: Convert coverage to lcov 37 | uses: jandelgado/gcov2lcov-action@v1.0.8 38 | with: 39 | working-directory: coverage 40 | 41 | - name: Coveralls 42 | uses: coverallsapp/github-action@v1.1.2 43 | with: 44 | github-token: ${{ secrets.GITHUB_TOKEN }} 45 | path-to-lcov: coverage/coverage.lcov 46 | -------------------------------------------------------------------------------- /extras/queryproxy/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 1; 3 | 4 | events { 5 | worker_connections 1024; 6 | } 7 | 8 | http { 9 | include /etc/nginx/mime.types; 10 | 11 | server { 12 | listen 1026; 13 | 14 | location / { 15 | proxy_pass http://orion:1026; 16 | proxy_set_header Host $host; 17 | proxy_set_header X-Real-IP $remote_addr; 18 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 19 | } 20 | 21 | location /v2/ex/entities { 22 | proxy_pass http://queryproxy:1030; 23 | proxy_set_header Host $host; 24 | proxy_set_header X-Real-IP $remote_addr; 25 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 26 | } 27 | location /health { 28 | proxy_pass http://queryproxy:1030; 29 | proxy_set_header Host $host; 30 | proxy_set_header X-Real-IP $remote_addr; 31 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2024 Kazuhito Suda 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/linters/.golangci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ######################### 3 | ######################### 4 | ## Golang Linter rules ## 5 | ######################### 6 | ######################### 7 | 8 | # configure golangci-lint 9 | # see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml 10 | issues: 11 | exclude-rules: 12 | - path: _test\.go 13 | linters: 14 | - dupl 15 | - gosec 16 | - goconst 17 | linters: 18 | enable: 19 | - golint 20 | # - gosec 21 | # - unconvert 22 | # - gocyclo 23 | # - goconst 24 | # - goimports 25 | # - maligned 26 | # - gocritic 27 | #linters-settings: 28 | # errcheck: 29 | # # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; 30 | # # default is false: such cases aren't reported by default. 31 | # check-blank: false 32 | # govet: 33 | # # report about shadowed variables 34 | # check-shadowing: true 35 | # gocyclo: 36 | # # minimal code complexity to report, 30 by default 37 | # min-complexity: 15 38 | # maligned: 39 | # # print struct with more effective memory layout or not, false by default 40 | # suggest-new: true 41 | -------------------------------------------------------------------------------- /extras/keycloak/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | 5 | postgres: 6 | image: postgres:13.3 7 | environment: 8 | POSTGRES_USER: keycloak 9 | POSTGRES_PASSWORD: password 10 | volumes: 11 | - ./postgres:/docker-entrypoint-initdb.d 12 | 13 | keycloak: 14 | image: quay.io/keycloak/keycloak:14.0.0 15 | environment: 16 | DB_VENDOR: POSTGRES 17 | DB_ADDR: postgres 18 | DB_DATABASE: keycloak 19 | DB_USER: keycloak 20 | DB_SCHEMA: public 21 | DB_PASSWORD: password 22 | KEYCLOAK_USER: admin 23 | KEYCLOAK_PASSWORD: 1234 24 | depends_on: 25 | - postgres 26 | 27 | nginx: 28 | image: nginx:1.19.10 29 | ports: 30 | - 80:80 31 | - 1026:1026 32 | volumes: 33 | - ./nginx.conf:/etc/nginx/nginx.conf:ro 34 | - ./keycloak_oauth2.js:/etc/nginx/keycloak_oauth2.js:ro 35 | depends_on: 36 | - orion 37 | - keycloak 38 | 39 | orion: 40 | image: fiware/orion:3.1.0 41 | depends_on: 42 | - mongo 43 | command: -dbhost mongo 44 | 45 | mongo: 46 | image: mongo:4.4 47 | command: --nojournal 48 | -------------------------------------------------------------------------------- /docs/install.md: -------------------------------------------------------------------------------- 1 | # Install 2 | 3 | ## Install NGSI Go binary 4 | 5 | The NGSI Go binary is installed in `/usr/local/bin`. 6 | 7 | ### Installation on Linux 8 | 9 | ```console 10 | curl -OL https://github.com/lets-fiware/ngsi-go/releases/download/v0.13.0/ngsi-v0.13.0-linux-amd64.tar.gz 11 | sudo tar zxvf ngsi-v0.13.0-linux-amd64.tar.gz -C /usr/local/bin 12 | ``` 13 | 14 | `ngsi-v0.13.0-linux-arm.tar.gz` and `ngsi-v0.13.0-linux-arm64.tar.gz` binaries are also available. 15 | 16 | ### Installation on Mac 17 | 18 | ```console 19 | curl -OL https://github.com/lets-fiware/ngsi-go/releases/download/v0.13.0/ngsi-v0.13.0-darwin-amd64.tar.gz 20 | sudo tar zxvf ngsi-v0.13.0-darwin-amd64.tar.gz -C /usr/local/bin 21 | ``` 22 | 23 | `ngsi-v0.13.0-darwin-arm64.tar.gz` binary is also available. 24 | 25 | ## Install bash autocomplete file for NGSI Go 26 | 27 | Install ngsi_bash_autocomplete file in `/etc/bash_completion.d`. 28 | 29 | ```console 30 | curl -OL https://raw.githubusercontent.com/lets-fiware/ngsi-go/main/autocomplete/ngsi_bash_autocomplete 31 | sudo mv ngsi_bash_autocomplete /etc/bash_completion.d/ 32 | source /etc/bash_completion.d/ngsi_bash_autocomplete 33 | echo "source /etc/bash_completion.d/ngsi_bash_autocomplete" >> ~/.bashrc 34 | ``` 35 | -------------------------------------------------------------------------------- /docs/wirecloud/preferences.md: -------------------------------------------------------------------------------- 1 | # preferences - Application mashup command 2 | 3 | This command manages preferences for WireCloud. 4 | 5 | - [Get preferences](#get-preferences) 6 | 7 | ## Common Options 8 | 9 | | Options | Description | 10 | | ---------------------- | -------------------------------------- | 11 | | --host VALUE, -h VALUE | broker or server host VALUE (required) | 12 | | --help | show help (default: true) | 13 | 14 | 15 | 16 | ## Get preferences 17 | 18 | This command gets preferences. 19 | 20 | ```console 21 | ngsi preferences [options] get 22 | ``` 23 | 24 | ## Options 25 | 26 | | Options | Description | 27 | | ---------------------- | -------------------------------------- | 28 | | --host VALUE, -h VALUE | broker or server host VALUE (required) | 29 | | --pretty, -P | pretty format (default: false) | 30 | | --help | show help (default: true) | 31 | 32 | ### Example 33 | 34 | ```console 35 | ngsi preferences --host wirecloud get --pretty 36 | ``` 37 | 38 | ```json 39 | { 40 | "language": { 41 | "inherit": false, 42 | "value": "default" 43 | } 44 | } 45 | ``` 46 | -------------------------------------------------------------------------------- /e2e/ngsi-test/9999_HALT: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 9999 halt 29 | # 30 | halt 31 | -------------------------------------------------------------------------------- /extras/keyrock/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | 5 | keyrock: 6 | image: fiware/idm:8.0.0-distroless 7 | depends_on: 8 | - mysql 9 | ports: 10 | - 3000:3000 11 | environment: 12 | - IDM_DB_HOST=mysql 13 | - IDM_ADMIN_USER=admin 14 | - IDM_ADMIN_EMAIL=admin@test.com 15 | - IDM_ADMIN_PASS=1234 16 | 17 | orion-proxy: 18 | image: fiware/pep-proxy:8.0.0-distroless 19 | depends_on: 20 | - keyrock 21 | - orion 22 | ports: 23 | - 1026:1026 24 | environment: 25 | - PEP_PROXY_DEBUG=true 26 | - PEP_PROXY_APP_HOST=orion 27 | - PEP_PROXY_APP_PORT=1026 28 | - PEP_PROXY_PORT=1026 29 | - PEP_PROXY_IDM_HOST=keyrock 30 | - PEP_PROXY_IDM_PORT=3000 31 | - PEP_PROXY_APP_ID=a1a6048b-df1d-4d4f-9a08-5cf836041d14 32 | - PEP_PROXY_USERNAME=pep_proxy_58b1a6db-1bc0-4323-837e-f100511af19c 33 | - PEP_PASSWORD=pep_proxy_1bad5dbf-7ae9-49a8-b0f6-c66e4570357a 34 | 35 | orion: 36 | image: fiware/orion:3.1.0 37 | depends_on: 38 | - mongo 39 | command: -dbhost mongo 40 | 41 | mongo: 42 | image: mongo:4.4 43 | command: --nojournal 44 | 45 | mysql: 46 | image: mysql:5.7 47 | environment: 48 | - MYSQL_ROOT_PASSWORD=1234 49 | volumes: 50 | - ./mysql:/docker-entrypoint-initdb.d/:ro 51 | -------------------------------------------------------------------------------- /docs/convenience/rm.md: -------------------------------------------------------------------------------- 1 | # rm - Convenience command 2 | 3 | This command removes all entities of an entity type specified by the `--type` option. 4 | 5 | ```console 6 | ngsi rm [options] 7 | ``` 8 | 9 | ## Options 10 | 11 | | Options | Description | 12 | | ------------------------- | --------------------------------------------- | 13 | | --host VALUE, -h VALUE | broker or server host VALUE (required) | 14 | | --service VALUE, -s VALUE | FIWARE Service VALUE | 15 | | --path VALUE, -p VALUE | FIWARE ServicePath VALUE | 16 | | --type VALUE, -t VALUE | Entity Type (required) | 17 | | --link VALUE, -L VALUE | @context VALUE (LD) | 18 | | --ngsiV1 | NGSI v1 mode (default: false) | 19 | | --skipForwarding | skip forwarding to CPrs (v2) (default: false) | 20 | | --run | run command (default: false) | 21 | | --help | show help (default: true) | 22 | 23 | ### Example 24 | 25 | ```console 26 | ngsi rm --host orion --type EvacuationSpace --run 27 | ``` 28 | 29 | ```console 30 | ngsi rm --type Device,Event,Thing --run 31 | ``` 32 | 33 | ```console 34 | ngsi rm --type AEDFacilities --ngsiV1 --run 35 | ``` 36 | -------------------------------------------------------------------------------- /e2e/ngsi-test/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package main 31 | 32 | import ( 33 | "os" 34 | ) 35 | 36 | func main() { 37 | os.Exit(ngsiTest()) 38 | } 39 | -------------------------------------------------------------------------------- /extras/apikey/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | 5 | keyrock: 6 | image: fiware/idm:8.0.0-distroless 7 | depends_on: 8 | - mysql 9 | ports: 10 | - 3000:3000 11 | environment: 12 | - IDM_DB_HOST=mysql 13 | - IDM_ADMIN_USER=admin 14 | - IDM_ADMIN_EMAIL=admin@test.com 15 | - IDM_ADMIN_PASS=1234 16 | 17 | orion-proxy: 18 | image: fiware/pep-proxy:8.0.0-distroless 19 | depends_on: 20 | - keyrock 21 | - orion 22 | ports: 23 | - 1026:1026 24 | environment: 25 | - PEP_PROXY_DEBUG=true 26 | - PEP_PROXY_APP_HOST=orion 27 | - PEP_PROXY_APP_PORT=1026 28 | - PEP_PROXY_PORT=1026 29 | - PEP_PROXY_IDM_HOST=keyrock 30 | - PEP_PROXY_IDM_PORT=3000 31 | - PEP_PROXY_APP_ID=a1a6048b-df1d-4d4f-9a08-5cf836041d14 32 | - PEP_PROXY_USERNAME=pep_proxy_58b1a6db-1bc0-4323-837e-f100511af19c 33 | - PEP_PASSWORD=pep_proxy_1bad5dbf-7ae9-49a8-b0f6-c66e4570357a 34 | - PEP_PROXY_MAGIC_KEY=magic1234 35 | 36 | orion: 37 | image: fiware/orion:3.1.0 38 | depends_on: 39 | - mongo 40 | command: -dbhost mongo 41 | 42 | mongo: 43 | image: mongo:4.4 44 | command: --nojournal 45 | 46 | mysql: 47 | image: mysql:5.7 48 | environment: 49 | - MYSQL_ROOT_PASSWORD=1234 50 | volumes: 51 | - ./mysql:/docker-entrypoint-initdb.d/:ro 52 | -------------------------------------------------------------------------------- /e2e/cases/3000_management/0501_license.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 Print OSS license information 29 | # 30 | ngsi license 31 | 32 | ``` 33 | ``` 34 | -------------------------------------------------------------------------------- /e2e/cases/6000_time_series/1000_comet/0001_comet_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 comet version 29 | # 30 | ngsi version --host $comet 31 | 32 | ``` 33 | {"version":"REGEX(.*)"} 34 | ``` 35 | -------------------------------------------------------------------------------- /e2e/cases/6200_perseo/1000_perseo-core_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 ngsi version --host perseo --pretty 29 | # 30 | ngsi version --host perseo-core --pretty 31 | 32 | ``` 33 | 1.13.0 34 | ``` 35 | -------------------------------------------------------------------------------- /e2e/cases/6300_cygnus/0003_cygnus_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 version --host cygnus 29 | # 30 | ngsi version --host cygnus 31 | 32 | ``` 33 | {"success":"true","version":"REGEX(.*)"} 34 | ``` 35 | -------------------------------------------------------------------------------- /script/unit-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2024 Kazuhito Suda 6 | # 7 | # This file is part of NGSI Go 8 | # 9 | # https://github.com/lets-fiware/ngsi-go 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documentation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in all 19 | # copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | # SOFTWARE. 28 | 29 | set -e 30 | 31 | if [ -e unit-test.sh ]; then 32 | cd .. 33 | fi 34 | 35 | cd internal 36 | go test -coverprofile=../coverage/coverage.out -covermode=atomic ./... 37 | -------------------------------------------------------------------------------- /e2e/cases/6000_time_series/2000_quantumleap/0001_quantumleap_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 quantumleap version 29 | # 30 | ngsi version --host quantumleap 31 | 32 | ``` 33 | { 34 | "version": "REGEX(.*)" 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /internal/ngsilib/ziplib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "bytes" 34 | "testing" 35 | ) 36 | 37 | func TestZipNewReader(t *testing.T) { 38 | z := zipLib{} 39 | src := bytes.NewReader([]byte("")) 40 | 41 | _, _ = z.NewReader(src, -1) 42 | } 43 | -------------------------------------------------------------------------------- /docs/convenience/version.md: -------------------------------------------------------------------------------- 1 | # version - Convenience command 2 | 3 | This command prints the version of Context Broker host specified by the `--host` option. 4 | 5 | ```console 6 | ngsi version [options] 7 | ``` 8 | 9 | ## Options 10 | 11 | | Options | Description | 12 | | ---------------------- | -------------------------------------- | 13 | | --host VALUE, -h VALUE | broker or server host VALUE (required) | 14 | | --pretty, -P | pretty format (default: false) | 15 | | --help | show help (default: true) | 16 | 17 | ### Example 18 | 19 | ```console 20 | ngsi version -h orion 21 | ``` 22 | 23 | ```json 24 | { 25 | "orion" : { 26 | "version" : "3.7.0", 27 | "uptime" : "0 d, 0 h, 0 m, 1 s", 28 | "git_hash" : "8b19705a8ec645ba1452cb97847a5615f0b2d3ca", 29 | "compile_time" : "Thu May 26 11:45:49 UTC 2022", 30 | "compiled_by" : "root", 31 | "compiled_in" : "025d96e1419a", 32 | "release_date" : "Thu May 26 11:45:49 UTC 2022", 33 | "machine" : "x86_64", 34 | "doc" : "https://fiware-orion.rtfd.io/en/3.7.0/", 35 | "libversions": { 36 | "boost": "1_74", 37 | "libcurl": "libcurl/7.74.0 OpenSSL/1.1.1n zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3", 38 | "libmosquitto": "2.0.12", 39 | "libmicrohttpd": "0.9.70", 40 | "openssl": "1.1", 41 | "rapidjson": "1.1.0", 42 | "mongoc": "1.17.4", 43 | "bson": "1.17.4" 44 | } 45 | } 46 | } 47 | ``` 48 | -------------------------------------------------------------------------------- /e2e/cases/1000_common/0002_ngsi_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 ngsi --version 29 | # 30 | ngsi --version 31 | 32 | ``` 33 | ngsi version REGEX(.*) 34 | ``` 35 | 36 | # 37 | # 0002 ngsi --serial 38 | # 39 | ngsi --serial 40 | 41 | ``` 42 | REGEX([0-9]+) 43 | ``` 44 | -------------------------------------------------------------------------------- /e2e/cases/2000_convenience/0201_cp_command.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 1000 copy008 cannot copy entities from NGSI-LD to NGSI v2 29 | # 30 | ngsi cp --host orion-ld --host2 orion --type device 31 | 32 | ```1 33 | copy003 cannot copy entities from NGSI-LD to NGSI v2 34 | ``` 35 | -------------------------------------------------------------------------------- /docs/management/token.md: -------------------------------------------------------------------------------- 1 | # Token - Management command 2 | 3 | This command gets an oauth token and prints a token information. 4 | 5 | ```console 6 | ngsi token [options] 7 | ``` 8 | 9 | ## Options 10 | 11 | | Options | Description | 12 | | ---------------------- | ------------------------------ | 13 | | --host VALUE, -h VALUE | broker or server host VALUE | 14 | | --verbose, -v | verbose (default: false) | 15 | | --pretty, -P | pretty format (default: false) | 16 | | --expires, -e | expires (default: false) | 17 | | --revoke, -r | revoke token (default: false) | 18 | | --help | show help (default: true) | 19 | 20 | ### Example 1 21 | 22 | ```console 23 | ngsi token -h orion 24 | ``` 25 | 26 | ```text 27 | 8385a04bd4e3d1da323843f32a18c9e0d5ad42e1 28 | ``` 29 | 30 | ### Example 2 31 | 32 | ```console 33 | export TOKEN=`ngsi token -h orion` 34 | echo $TOKEN 35 | 63dcaf3e87d9775578b46a7bb046be74365e9b96 36 | ``` 37 | 38 | ### Example 3 39 | 40 | Get detailed information about a token 41 | 42 | ```console 43 | ngsi token -h orion --verbose 44 | ``` 45 | 46 | ```json 47 | {"AccessToken":"7385a04bd4e3d1da723843f32a18c9e0d5ad42c9","ExpiresIn":3599,"RefreshToken":"59580f9a024ad8a28464e8be024b5c753dea2b9c","Scope":["bearer"],"TokenType":"Bearer"} 48 | ``` 49 | 50 | ### Example 4 51 | 52 | Get the number of seconds until a token expires 53 | 54 | ```console 55 | ngsi token -h orion --expires 56 | ``` 57 | 58 | ```text 59 | 2045 60 | ``` 61 | -------------------------------------------------------------------------------- /internal/ngsilib/syslog_lib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "testing" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/assert" 36 | ) 37 | 38 | func TestSyslogNew(t *testing.T) { 39 | s := syslogLib{} 40 | 41 | _, err := s.New() 42 | 43 | assert.NoError(t, err) 44 | } 45 | -------------------------------------------------------------------------------- /tools/mdlint/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM node:14 28 | 29 | WORKDIR / 30 | COPY package.json . 31 | COPY package-lock.json . 32 | RUN npm ci && \ 33 | ln -s /node_modules/remark-cli/cli.js /usr/local/bin/remark 34 | 35 | WORKDIR /work 36 | 37 | ENTRYPOINT ["/usr/local/bin/remark"] 38 | -------------------------------------------------------------------------------- /internal/cygnus/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package cygnus 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | -------------------------------------------------------------------------------- /internal/iotagent/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package iotagent 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | -------------------------------------------------------------------------------- /internal/keyrock/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package keyrock 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | -------------------------------------------------------------------------------- /internal/ngsicmd/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsicmd 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | -------------------------------------------------------------------------------- /internal/perseo/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package perseo 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | -------------------------------------------------------------------------------- /extras/tokenproxy/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | 5 | tokenproxy: 6 | image: letsfiware/tokenproxy:1.0 7 | build: ./ 8 | ports: 9 | - "1029:1029" 10 | depends_on: 11 | - keyrock 12 | 13 | keyrock: 14 | image: fiware/idm:8.0.0-distroless 15 | depends_on: 16 | - mysql 17 | ports: 18 | - 3000:3000 19 | environment: 20 | - IDM_DB_HOST=mysql 21 | - IDM_ADMIN_USER=admin 22 | - IDM_ADMIN_EMAIL=admin@test.com 23 | - IDM_ADMIN_PASS=1234 24 | 25 | orion-proxy: 26 | image: fiware/pep-proxy:8.0.0-distroless 27 | depends_on: 28 | - keyrock 29 | - orion 30 | ports: 31 | - 1026:1026 32 | environment: 33 | - PEP_PROXY_DEBUG=true 34 | - PEP_PROXY_APP_HOST=orion 35 | - PEP_PROXY_APP_PORT=1026 36 | - PEP_PROXY_PORT=1026 37 | - PEP_PROXY_IDM_HOST=keyrock 38 | - PEP_PROXY_IDM_PORT=3000 39 | - PEP_PROXY_APP_ID=a1a6048b-df1d-4d4f-9a08-5cf836041d14 40 | - PEP_PROXY_USERNAME=pep_proxy_58b1a6db-1bc0-4323-837e-f100511af19c 41 | - PEP_PASSWORD=pep_proxy_1bad5dbf-7ae9-49a8-b0f6-c66e4570357a 42 | - PEP_PROXY_MAGIC_KEY=magic1234 43 | 44 | orion: 45 | image: fiware/orion:3.1.0 46 | depends_on: 47 | - mongo 48 | command: -dbhost mongo 49 | 50 | mongo: 51 | image: mongo:4.4 52 | command: --nojournal 53 | 54 | mysql: 55 | image: mysql:5.7 56 | environment: 57 | - MYSQL_ROOT_PASSWORD=1234 58 | volumes: 59 | - ./mysql:/docker-entrypoint-initdb.d/:ro 60 | -------------------------------------------------------------------------------- /internal/timeseries/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package timeseries 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | -------------------------------------------------------------------------------- /internal/wirecloud/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package wirecloud 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | -------------------------------------------------------------------------------- /script/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2024 Kazuhito Suda 6 | # 7 | # This file is part of NGSI Go 8 | # 9 | # https://github.com/lets-fiware/ngsi-go 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documentation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in all 19 | # copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | # SOFTWARE. 28 | 29 | set -e 30 | 31 | if [ -e coverage.sh ]; then 32 | cd .. 33 | fi 34 | 35 | cd internal 36 | go test -coverprofile=../coverage/coverage.out -covermode=atomic ./... 37 | cd .. 38 | go tool cover -html=coverage/coverage.out -o coverage/coverage.html 39 | -------------------------------------------------------------------------------- /tools/textlint/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM node:14 28 | 29 | WORKDIR / 30 | COPY package.json . 31 | COPY package-lock.json . 32 | RUN npm ci && \ 33 | ln -s /node_modules/textlint/bin/textlint.js /usr/local/bin/textlint 34 | 35 | WORKDIR /work 36 | 37 | ENTRYPOINT ["/usr/local/bin/textlint"] 38 | -------------------------------------------------------------------------------- /script/release_buildx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2024 Kazuhito Suda 6 | # 7 | # This file is part of NGSI Go 8 | # 9 | # https://github.com/lets-fiware/ngsi-go 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documentation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in all 19 | # copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | # SOFTWARE. 28 | 29 | set -e 30 | 31 | if [ -e release_buildx.sh ]; then 32 | cd .. 33 | fi 34 | 35 | NGSIGO_TARGET=$1 36 | if [ -z "$NGSIGO_TARGET" ]; then 37 | NGSIGO_TARGET=build-all 38 | fi 39 | export NGSIGO_TARGET 40 | cd docker 41 | make build 42 | make run 43 | -------------------------------------------------------------------------------- /tools/mdlint/Makefile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | curdir = $(shell pwd) 28 | files = -f '.' 29 | container = letsfiware/mdlint:1.0 30 | vol = -v $(curdir):/work 31 | 32 | build: 33 | docker build -t $(container) . 34 | pull: 35 | docker pull $(container) 36 | run: 37 | docker run --rm -t $(vol) $(container) $(files) 38 | -------------------------------------------------------------------------------- /e2e/cases/6100_iot_agent/0011_iota_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 ngsi version --host iota --pretty 29 | # 30 | ngsi version --host iota --pretty 31 | 32 | ``` 33 | { 34 | "libVersion": "REGEX(.*)", 35 | "port": "REGEX(.*)", 36 | "baseRoot": "REGEX(.*)", 37 | "version": "REGEX(.*)" 38 | } 39 | ``` 40 | -------------------------------------------------------------------------------- /internal/helper/zip_file.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "io" 34 | ) 35 | 36 | type MockZipFile struct { 37 | } 38 | 39 | func (f *MockZipFile) DataOffset() (offset int64, err error) { 40 | return 0, nil 41 | 42 | } 43 | 44 | func (f *MockZipFile) Open() (io.ReadCloser, error) { 45 | return nil, nil 46 | } 47 | -------------------------------------------------------------------------------- /script/lint-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2024 Kazuhito Suda 6 | # 7 | # This file is part of NGSI Go 8 | # 9 | # https://github.com/lets-fiware/ngsi-go 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documentation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in all 19 | # copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | # SOFTWARE. 28 | 29 | set -e 30 | 31 | cd $(dirname $0) 32 | cd .. 33 | 34 | # md lint 35 | cd tools/mdlint 36 | make build 37 | cd - 38 | make -f tools/mdlint/Makefile run 39 | 40 | # textfile lint 41 | cd tools/textlint 42 | make build 43 | cd - 44 | make -f tools/textlint/Makefile run 45 | -------------------------------------------------------------------------------- /internal/convenience/documents_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package convenience 31 | 32 | import ( 33 | "testing" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/assert" 36 | ) 37 | 38 | func TestDocuments(t *testing.T) { 39 | c := setupTest([]string{"man"}) 40 | 41 | err := documents(c, c.Ngsi, c.Client) 42 | 43 | assert.NoError(t, err) 44 | } 45 | -------------------------------------------------------------------------------- /tools/textlint/Makefile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | curdir = $(shell pwd) 28 | files = '*.md' 'docs/*.md' 29 | container = letsfiware/textlint:1.0 30 | vol = -v $(curdir):/work 31 | 32 | build: 33 | docker build -t $(container) . 34 | pull: 35 | docker pull $(container) 36 | run: 37 | docker run --rm -t $(vol) $(container) $(files) 38 | -------------------------------------------------------------------------------- /e2e/cases/6000_time_series/2000_quantumleap/0002_quantumleap_health.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 wait for quantumleap 29 | # 30 | wait ${quantumleap}/health --retry 600 --status pass 31 | 32 | # 33 | # 0002 quantumleap health 34 | # 35 | ngsi health --host quantumleap 36 | 37 | ``` 38 | { 39 | "status": "pass" 40 | } 41 | ``` 42 | -------------------------------------------------------------------------------- /e2e/cases/6500_keyrock/1000_service_provider.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 Get service providers 29 | # 30 | ngsi providers --host keyrock --pretty 31 | 32 | ``` 33 | { 34 | "information": { 35 | "total_users": REGEX(.*), 36 | "total_organizations": REGEX(.*), 37 | "total_applications": REGEX(.*) 38 | } 39 | } 40 | ``` 41 | -------------------------------------------------------------------------------- /docker/Makefile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | curdir = $(shell pwd) 28 | container = ngsi-cmd-build 29 | env = -e GITHUB=$(NGSIGO_GITHUB) -e USER_ID=$(shell id -u) -e GROUP_ID=$(shell id -g) -e NGSIGO_TARGET 30 | vol = -v $(curdir)/../build:/build 31 | 32 | build: 33 | docker build -t $(container) . 34 | run: 35 | docker run -it --rm $(env) $(vol) $(container) 36 | -------------------------------------------------------------------------------- /e2e/cases/6200_perseo/0002_perseo_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 ngsi version --host perseo --pretty 29 | # 30 | ngsi version --host perseo --pretty 31 | 32 | ``` 33 | { 34 | "error": null, 35 | "data": { 36 | "name": "perseo", 37 | "description": "IOT CEP front End", 38 | "version": "REGEX(.*)" 39 | } 40 | } 41 | ``` 42 | -------------------------------------------------------------------------------- /internal/ngsicli/args.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsicli 31 | 32 | type Args interface { 33 | Get(n int) string 34 | Len() int 35 | } 36 | 37 | type cmdArgs []string 38 | 39 | func (a *cmdArgs) Get(i int) string { 40 | if len(*a) > i && i >= 0 { 41 | return (*a)[i] 42 | } 43 | return "" 44 | } 45 | 46 | func (a *cmdArgs) Len() int { 47 | return len(*a) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/ngsi/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package main 31 | 32 | import ( 33 | "os" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/ngsimain" 36 | ) 37 | 38 | var version = "0.13.0-next" 39 | var revision = "" 40 | 41 | func main() { 42 | ngsimain.Version = version 43 | ngsimain.Revision = revision 44 | os.Exit(ngsimain.Run(os.Args, os.Stdin, os.Stdout, os.Stderr)) 45 | } 46 | -------------------------------------------------------------------------------- /docker/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # MIT License 3 | # 4 | # Copyright (c) 2020-2024 Kazuhito Suda 5 | # 6 | # This file is part of NGSI Go 7 | # 8 | # https://github.com/lets-fiware/ngsi-go 9 | # 10 | # Permission is hereby granted, free of charge, to any person obtaining a copy 11 | # of this software and associated documentation files (the "Software"), to deal 12 | # in the Software without restriction, including without limitation the rights 13 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | # copies of the Software, and to permit persons to whom the Software is 15 | # furnished to do so, subject to the following conditions: 16 | # 17 | # The above copyright notice and this permission notice shall be included in all 18 | # copies or substantial portions of the Software. 19 | # 20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | # SOFTWARE. 27 | 28 | git clone "https://github.com/lets-fiware/ngsi-go.git" 29 | cd ngsi-go || exit 1 30 | rm -fr build 31 | ln -s /build . 32 | rm -fr build/* 33 | touch build/.gitkeep 34 | make devel-deps || exit 1 35 | echo "TARGET: $NGSIGO_TARGET" 36 | make "$NGSIGO_TARGET" || exit 1 37 | chown -R "$USER_ID":"$GROUP_ID" /build 38 | -------------------------------------------------------------------------------- /internal/helper/syslog_lib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "bytes" 34 | "io" 35 | ) 36 | 37 | type MockSyslogLib struct { 38 | Err error 39 | Buf *bytes.Buffer 40 | } 41 | 42 | func (s *MockSyslogLib) New() (io.Writer, error) { 43 | if s.Err == nil { 44 | s.Buf = new(bytes.Buffer) 45 | return s.Buf, nil 46 | } 47 | return nil, s.Err 48 | } 49 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM golang:1.20.6-alpine3.18 AS builder 28 | 29 | # hadolint ignore=DL3018 30 | RUN \ 31 | apk update && \ 32 | apk add --no-cache \ 33 | make \ 34 | git 35 | 36 | WORKDIR /root/go/src/github.com/lets-fiware 37 | 38 | COPY build.sh /root/go/src/github.com/lets-fiware 39 | 40 | 41 | CMD ["./build.sh"] 42 | -------------------------------------------------------------------------------- /script/e2e-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2024 Kazuhito Suda 6 | # 7 | # This file is part of NGSI Go 8 | # 9 | # https://github.com/lets-fiware/ngsi-go 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documentation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in all 19 | # copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | # SOFTWARE. 28 | 29 | set -e 30 | 31 | if [ -e e2e-test.sh ]; then 32 | cd .. 33 | fi 34 | 35 | if [ -e ./bin/ngsi ]; then 36 | rm -f ./bin/ngsi 37 | fi 38 | 39 | make build 40 | cd e2e 41 | if [ ! "$(docker compose ps -a | wc -l)" = "2" ]; then 42 | make down 43 | fi 44 | make build 45 | make rmi 46 | make up 47 | make run_e2e_test 48 | -------------------------------------------------------------------------------- /e2e/cases/6300_cygnus/0001_cygnus.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0011 server list 29 | # 30 | ngsi server list 31 | 32 | ``` 33 | comet cygnus iota keyrock perseo perseo-core quantumleap wirecloud 34 | ``` 35 | 36 | # 37 | # 0012 server list --host cygnus 38 | # 39 | ngsi server list --host cygnus 40 | 41 | ``` 42 | serverType cygnus 43 | serverHost http://cygnus:5080 44 | ``` 45 | -------------------------------------------------------------------------------- /internal/ngsilib/syslog_lib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "io" 34 | "log/syslog" 35 | ) 36 | 37 | // SyslogLib is ... 38 | type SyslogLib interface { 39 | New() (io.Writer, error) 40 | } 41 | 42 | type syslogLib struct{} 43 | 44 | func (s *syslogLib) New() (io.Writer, error) { 45 | w, err := syslog.New(syslog.LOG_NOTICE|syslog.LOG_USER, "ngsi-go") 46 | return w, err 47 | } 48 | -------------------------------------------------------------------------------- /internal/ngsilib/ziplib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "archive/zip" 34 | "io" 35 | ) 36 | 37 | // ZipLib is ... 38 | type ZipLib interface { 39 | NewReader(r io.ReaderAt, size int64) (*zip.Reader, error) 40 | } 41 | 42 | type zipLib struct { 43 | } 44 | 45 | func (z *zipLib) NewReader(r io.ReaderAt, size int64) (*zip.Reader, error) { 46 | return zip.NewReader(r, size) 47 | } 48 | -------------------------------------------------------------------------------- /e2e/cases/6400_wirecloud/0001_wirecloud.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0011 server list 29 | # 30 | ngsi server list 31 | 32 | ``` 33 | comet cygnus iota keyrock perseo perseo-core quantumleap wirecloud 34 | ``` 35 | 36 | # 37 | # 0012 server list --host wirecloud 38 | # 39 | ngsi server list --host wirecloud 40 | 41 | ``` 42 | serverType wirecloud 43 | serverHost http://wirecloud:8000 44 | ``` 45 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Proposed changes 2 | 3 | Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. 4 | If it fixes a bug or resolves a feature request, be sure to link to that issue. 5 | 6 | ## Types of changes 7 | 8 | What types of changes does your code introduce to the project: _Put an `x` in the boxes that apply_ 9 | 10 | - [ ] Bugfix (non-breaking change which fixes an issue) 11 | - [ ] New feature (non-breaking change which adds functionality) 12 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 13 | - [ ] Update only documentation, not any source code. 14 | 15 | ## Checklist 16 | 17 | _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of 18 | them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before 19 | merging your code._ 20 | 21 | - [ ] I have read the [CONTRIBUTING](https://github.com/lets-fiware/ngsi-go/blob/main/CONTRIBUTING.md) doc 22 | - [ ] I have signed the [CLA](https://github.com/lets-fiware/ngsi-go/blob/main/ngsi-go-individual-cla.pdf) 23 | - [ ] I have added tests that prove my fix is effective or that my feature works 24 | - [ ] I have added necessary documentation (if appropriate) 25 | - [ ] Any dependent changes have been merged and published in downstream modules 26 | 27 | ## Further comments 28 | 29 | If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you 30 | did and what alternatives you considered, etc... 31 | -------------------------------------------------------------------------------- /e2e/Makefile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | build: 28 | docker compose build --no-cache 29 | up: 30 | script/docker-compose-up.sh 31 | down: 32 | docker compose down 33 | ps: 34 | docker compose ps 35 | logs: 36 | docker compose logs 37 | rmi: 38 | script/rmi.sh 39 | shell: 40 | docker compose exec ngsi-test bash 41 | run_e2e_test: 42 | docker compose exec -T ngsi-test /usr/local/bin/ngsi-test -verbose cases/ 43 | -------------------------------------------------------------------------------- /e2e/cases/6300_cygnus/0060_metrics.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0011 cygnus metrics 29 | # 30 | ngsi admin --host cygnus metrics --pretty 31 | 32 | ``` 33 | { 34 | "services": {}, 35 | "sum": { 36 | "subservs": {}, 37 | "sum": {} 38 | } 39 | } 40 | ``` 41 | 42 | # 43 | # 0012 cygnus metrics --reset 44 | # 45 | ngsi admin --host cygnus metrics --reset 46 | 47 | ``` 48 | {"services":{},"sum": {"subservs":{},"sum":{}}} 49 | ``` 50 | -------------------------------------------------------------------------------- /script/all-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2024 Kazuhito Suda 6 | # 7 | # This file is part of NGSI Go 8 | # 9 | # https://github.com/lets-fiware/ngsi-go 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documentation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in all 19 | # copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | # SOFTWARE. 28 | 29 | set -e 30 | 31 | if [ -e all-tests.sh ]; then 32 | cd .. 33 | fi 34 | 35 | echo "*** build test ***" 36 | make build 37 | echo "*** unit test ***" 38 | make unit-test 39 | echo "*** e2e test ***" 40 | make e2e-test 41 | echo "*** golangci-lint" 42 | make golangci-lint 43 | echo "*** lint dockerfile ***" 44 | make lint-dockerfile 45 | echo "*** lint documentation ***" 46 | make lint-docs 47 | -------------------------------------------------------------------------------- /internal/ngsilib/filepathlib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import "testing" 33 | 34 | func TestFilePathLibFilePathAbs(t *testing.T) { 35 | f := filePathLib{} 36 | 37 | _, _ = f.FilePathAbs("") 38 | } 39 | 40 | func TestFilePathLibFilePathJoin(t *testing.T) { 41 | f := filePathLib{} 42 | 43 | _ = f.FilePathJoin("", "") 44 | } 45 | 46 | func TestFilePathLibFilePathBase(t *testing.T) { 47 | f := filePathLib{} 48 | 49 | _ = f.FilePathBase("") 50 | } 51 | -------------------------------------------------------------------------------- /e2e/cases/2000_convenience/0401_man_command.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0011 ngsi man 29 | # 30 | ngsi man 31 | 32 | ``` 33 | English: 34 | https://fiware-orion.readthedocs.io/ 35 | https://telefonicaid.github.io/fiware-orion/api/v2/stable/ 36 | https://ngsi-go.letsfiware.jp/ 37 | Japanese: 38 | https://fiware-orion.letsfiware.jp/ 39 | https://open-apis.letsfiware.jp/fiware-orion/api/v2/stable/ 40 | https://open-apis.letsfiware.jp/keyrock/ 41 | ``` 42 | -------------------------------------------------------------------------------- /internal/convenience/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package convenience 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | 41 | func setupTestWithConfig(args []string, config string) *ngsicli.Context { 42 | return helper.SetupTestWithConfig(NewNgsiApp(), args, config) 43 | } 44 | -------------------------------------------------------------------------------- /e2e/cases/6200_perseo/0001_perseo.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 ngsi settings clear 29 | # 30 | ngsi settings clear 31 | 32 | ``` 33 | ``` 34 | 35 | # 36 | # 0011 server list 37 | # 38 | ngsi server list 39 | 40 | ``` 41 | comet cygnus iota keyrock perseo perseo-core quantumleap wirecloud 42 | ``` 43 | 44 | # 45 | # 0012 server list --host perseo 46 | # 47 | ngsi server list --host perseo 48 | 49 | ``` 50 | serverType perseo 51 | serverHost http://perseo:9090 52 | ``` 53 | -------------------------------------------------------------------------------- /e2e/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # MIT License 3 | # 4 | # Copyright (c) 2020-2024 Kazuhito Suda 5 | # 6 | # This file is part of NGSI Go 7 | # 8 | # https://github.com/lets-fiware/ngsi-go 9 | # 10 | # Permission is hereby granted, free of charge, to any person obtaining a copy 11 | # of this software and associated documentation files (the "Software"), to deal 12 | # in the Software without restriction, including without limitation the rights 13 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | # copies of the Software, and to permit persons to whom the Software is 15 | # furnished to do so, subject to the following conditions: 16 | # 17 | # The above copyright notice and this permission notice shall be included in all 18 | # copies or substantial portions of the Software. 19 | # 20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | # SOFTWARE. 27 | 28 | set -eu 29 | 30 | if [ ! -e "$1" ]; then 31 | echo "$1 not found." 32 | fi 33 | 34 | set +e 35 | found=$(docker info --format '{{json . }}' | jq -r '.ClientInfo.Plugins | .[].Name' | ${GREP_CMD} -ic compose) 36 | set -e 37 | if [ "${found}" -eq 1 ]; then 38 | docker compose exec ngsi-test /usr/local/bin/ngsi-test -verbose "$1" 39 | else 40 | if [ -e /usr/local/bin/ngsi-test ]; then 41 | /usr/local/bin/ngsi-test -verbose "$1" 42 | fi 43 | fi 44 | -------------------------------------------------------------------------------- /docs/convenience/apis.md: -------------------------------------------------------------------------------- 1 | # apis- Convenience command 2 | 3 | This command prints the version of FIWARE GE specified by the `--host` option. 4 | 5 | ```console 6 | ngsi version [options] 7 | ``` 8 | 9 | ## Options 10 | 11 | | Options | Description | 12 | | ---------------------- | -------------------------------------- | 13 | | --host VALUE, -h VALUE | broker or server host VALUE (required) | 14 | | --pretty, -P | pretty format (default: false) | 15 | | --help | show help (default: true) | 16 | 17 | ### Example 18 | 19 | ```console 20 | ngsi version -h orion 21 | ``` 22 | 23 | ```json 24 | { 25 | "orion" : { 26 | "version" : "3.7.0", 27 | "uptime" : "0 d, 0 h, 0 m, 1 s", 28 | "git_hash" : "8b19705a8ec645ba1452cb97847a5615f0b2d3ca", 29 | "compile_time" : "Thu May 26 11:45:49 UTC 2022", 30 | "compiled_by" : "root", 31 | "compiled_in" : "025d96e1419a", 32 | "release_date" : "Thu May 26 11:45:49 UTC 2022", 33 | "machine" : "x86_64", 34 | "doc" : "https://fiware-orion.rtfd.io/en/3.7.0/", 35 | "libversions": { 36 | "boost": "1_74", 37 | "libcurl": "libcurl/7.74.0 OpenSSL/1.1.1n zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3", 38 | "libmosquitto": "2.0.12", 39 | "libmicrohttpd": "0.9.70", 40 | "openssl": "1.1", 41 | "rapidjson": "1.1.0", 42 | "mongoc": "1.17.4", 43 | "bson": "1.17.4" 44 | } 45 | } 46 | } 47 | ``` 48 | 49 | ```console 50 | ngsi version --host comet 51 | ``` 52 | 53 | ```json 54 | {"version":"2.8.0-next"} 55 | ``` 56 | 57 | ```console 58 | ngsi version --host quantumleap 59 | ``` 60 | 61 | ```json 62 | { 63 | "version": "0.7.6" 64 | } 65 | ``` 66 | -------------------------------------------------------------------------------- /e2e/tokenproxy/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM alpine:3.15 AS runner 28 | 29 | WORKDIR /opt/ngsi-go/ 30 | 31 | RUN chown -R nobody:nobody /opt/ngsi-go 32 | 33 | USER nobody 34 | 35 | ENTRYPOINT ["/usr/local/bin/ngsi"] 36 | CMD ["--stderr", "info", "--config", "./ngsi-go-config.json", "--cache", "./ngsi-go-token-cache.json", "tokenproxy", "server", "--idmHost", "http://keyrock:3000", "--clientId", "de95b7b2-2be4-46c8-89da-0aa633cd594c", "--clientSecret", "33b387a5-8926-448f-bb9e-644775cd0f74", "--verbose"] 37 | -------------------------------------------------------------------------------- /e2e/cases/6400_wirecloud/0002_wirecloud_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 version --host wirecloud 29 | # 30 | ngsi version --host wirecloud --pretty 31 | 32 | ``` 33 | { 34 | "ApplicationMashup": "REGEX(.*)", 35 | "ComponentManagement": "REGEX(.*)", 36 | "DashboardManagement": "REGEX(.*)", 37 | "FIWARE": "REGEX(.*)", 38 | "FullscreenWidget": "REGEX(.*)", 39 | "NGSI": "REGEX(.*)", 40 | "ObjectStorage": "REGEX(.*)", 41 | "StyledElements": "REGEX(.*)", 42 | "Wirecloud": "REGEX(.*)" 43 | } 44 | ``` 45 | -------------------------------------------------------------------------------- /internal/helper/filepath_lib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "path/filepath" 34 | "strings" 35 | ) 36 | 37 | type MockFilePathLib struct { 38 | PathAbsErr error 39 | } 40 | 41 | func (i *MockFilePathLib) FilePathAbs(path string) (string, error) { 42 | return path, i.PathAbsErr 43 | } 44 | 45 | func (i *MockFilePathLib) FilePathJoin(elem ...string) string { 46 | return strings.Join(elem, "/") 47 | } 48 | 49 | func (i *MockFilePathLib) FilePathBase(path string) string { 50 | return filepath.Base(path) 51 | } 52 | -------------------------------------------------------------------------------- /internal/helper/zip_file_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "io" 34 | "testing" 35 | 36 | "github.com/lets-fiware/ngsi-go/internal/assert" 37 | ) 38 | 39 | func TestZipFileDataOffset(t *testing.T) { 40 | z := &MockZipFile{} 41 | 42 | actual, err := z.DataOffset() 43 | 44 | if assert.NoError(t, err) { 45 | assert.Equal(t, int64(0), actual) 46 | } 47 | } 48 | 49 | func TestZipFileOpen(t *testing.T) { 50 | z := &MockZipFile{} 51 | 52 | actual, err := z.Open() 53 | 54 | if assert.NoError(t, err) { 55 | assert.Equal(t, (io.ReadCloser)(nil), actual) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /docs/convenience/cp.md: -------------------------------------------------------------------------------- 1 | # cp - Convenience command 2 | 3 | This command copies multiple entities from a source to a destination. 4 | 5 | ```console 6 | ngsi cp [options] 7 | ``` 8 | 9 | ## Options 10 | 11 | | Options | Description | 12 | | ------------------------- | --------------------------------------------- | 13 | | --host VALUE, -h VALUE | broker or server host VALUE (required) | 14 | | --host2 VALUE, -d VALUE | host or alias (required) | 15 | | --service VALUE, -s VALUE | FIWARE Service VALUE | 16 | | --path VALUE, -p VALUE | FIWARE ServicePath VALUE | 17 | | --link VALUE, -L VALUE | @context VALUE (LD) | 18 | | --type VALUE, -t VALUE | Entity Type (required) | 19 | | --service2 VALUE | FIWARE Service for destination | 20 | | --path2 VALUE | FIWARE ServicePath for destination | 21 | | --context2 VALUE | @context for destination | 22 | | --ngsiV1 | NGSI v1 mode (default: false) | 23 | | --skipForwarding | skip forwarding to CPrs (v2) (default: false) | 24 | | --run | run command (default: false) | 25 | | --help | show help (default: true) | 26 | 27 | ### Example 28 | 29 | #### Request: 30 | 31 | ```console 32 | ngsi cp --host orion1 --host2 orion2 --type EvacuationSpace --run 33 | ``` 34 | 35 | #### Request: 36 | 37 | ``` 38 | ngsi cp --run --host orion-ld --host2 orion-ld --service2 openiot --type TemperatureSensor --link ctx 39 | ``` 40 | 41 | #### Request: 42 | 43 | ``` 44 | ngsi cp --host orion --type TemperatureSensor --host2 orion-ld --context2 ctx --run 45 | ``` 46 | -------------------------------------------------------------------------------- /extras/registration_proxy/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | regproxy: 5 | image: letsfiware/regproxy:1.0 6 | build: ./ 7 | ports: 8 | - "1028:1028" 9 | depends_on: 10 | - keyrock 11 | - local-orion 12 | 13 | local-orion: 14 | image: fiware/orion:3.1.0 15 | ports: 16 | - "1026:1026" 17 | depends_on: 18 | - local-mongo 19 | command: -dbhost local-mongo 20 | 21 | local-mongo: 22 | image: mongo:4.4 23 | command: --nojournal 24 | 25 | keyrock: 26 | image: fiware/idm:8.0.0-distroless 27 | depends_on: 28 | - mysql 29 | ports: 30 | - 3000:3000 31 | environment: 32 | - IDM_DB_HOST=mysql 33 | - IDM_ADMIN_USER=admin 34 | - IDM_ADMIN_EMAIL=admin@test.com 35 | - IDM_ADMIN_PASS=1234 36 | 37 | orion-proxy: 38 | image: fiware/pep-proxy:8.0.0-distroless 39 | depends_on: 40 | - keyrock 41 | - remote-orion 42 | ports: 43 | - 1027:1026 44 | environment: 45 | - PEP_PROXY_DEBUG=true 46 | - PEP_PROXY_APP_HOST=remote-orion 47 | - PEP_PROXY_APP_PORT=1026 48 | - PEP_PROXY_PORT=1026 49 | - PEP_PROXY_IDM_HOST=keyrock 50 | - PEP_PROXY_IDM_PORT=3000 51 | - PEP_PROXY_APP_ID=a1a6048b-df1d-4d4f-9a08-5cf836041d14 52 | - PEP_PROXY_USERNAME=pep_proxy_58b1a6db-1bc0-4323-837e-f100511af19c 53 | - PEP_PASSWORD=pep_proxy_1bad5dbf-7ae9-49a8-b0f6-c66e4570357a 54 | 55 | remote-orion: 56 | image: fiware/orion:3.1.0 57 | depends_on: 58 | - remote-mongo 59 | command: -dbhost remote-mongo 60 | 61 | remote-mongo: 62 | image: mongo:4.4 63 | command: --nojournal 64 | 65 | mysql: 66 | image: mysql:5.7 67 | environment: 68 | - MYSQL_ROOT_PASSWORD=1234 69 | volumes: 70 | - ./mysql:/docker-entrypoint-initdb.d/:ro 71 | -------------------------------------------------------------------------------- /script/golangci-lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # MIT License 3 | # 4 | # Copyright (c) 2020-2024 Kazuhito Suda 5 | # 6 | # This file is part of NGSI Go 7 | # 8 | # https://github.com/lets-fiware/ngsi-go 9 | # 10 | # Permission is hereby granted, free of charge, to any person obtaining a copy 11 | # of this software and associated documentation files (the "Software"), to deal 12 | # in the Software without restriction, including without limitation the rights 13 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | # copies of the Software, and to permit persons to whom the Software is 15 | # furnished to do so, subject to the following conditions: 16 | # 17 | # The above copyright notice and this permission notice shall be included in all 18 | # copies or substantial portions of the Software. 19 | # 20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | # SOFTWARE. 27 | 28 | set -e 29 | 30 | if [ -e golangci-lint.sh ]; then 31 | cd .. 32 | fi 33 | 34 | for i in internal/assert internal/convenience internal/cygnus internal/helper internal/iotagent internal/keyrock internal/management internal/ngsicli internal/ngsicmd internal/ngsierr internal/ngsilib internal/ngsimain internal/perseo internal/timeseries internal/wirecloud e2e/ngsi-test e2e/server/accumulator e2e/server/atcontext e2e/server/csource e2e/server/oauth 35 | do 36 | echo "${i}" 37 | cd "${i}" 38 | golangci-lint run 39 | cd - > /dev/null 40 | done 41 | -------------------------------------------------------------------------------- /e2e/cases/6000_time_series/1000_comet/0002_create_historical_data.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 Check if comet is registered 29 | # 30 | ngsi server get --host comet 31 | 32 | ``` 33 | serverType comet 34 | serverHost http://comet:8666 35 | FIWARE-Service openiot 36 | FIWARE-ServicePath / 37 | ``` 38 | 39 | # 40 | # 0002 Clean up 41 | # 42 | ngsi hdelete --host comet --run 43 | 44 | # 45 | # 0003 Create historical data 46 | # 47 | createdata v1notify -url ${comet}/notify -dateTime 2016-09-13T00:00:00.000Z \ 48 | -count 3000 -id device001 --service openiot --path / --attrs A1 --values 1 --type Thing 49 | -------------------------------------------------------------------------------- /internal/helper/reader.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "errors" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/ngsilib" 36 | ) 37 | 38 | // MockReader 39 | func MockReadAll(s string) (bytes []byte, err error) { 40 | return ngsilib.ReadAll(s) 41 | } 42 | 43 | func MockReadAllError(s string) (bytes []byte, err error) { 44 | return nil, errors.New("readall error") 45 | } 46 | 47 | func MockGetReader(s string) (ngsilib.FileLib, error) { 48 | return ngsilib.GetReader(s) 49 | } 50 | 51 | func MockGetReaderError(s string) (ngsilib.FileLib, error) { 52 | return nil, errors.New("getreader error") 53 | } 54 | -------------------------------------------------------------------------------- /internal/helper/syslog_lib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "errors" 34 | "io" 35 | "testing" 36 | 37 | "github.com/lets-fiware/ngsi-go/internal/assert" 38 | ) 39 | 40 | func TestSyslogLibNew(t *testing.T) { 41 | s := MockSyslogLib{} 42 | 43 | w, err := s.New() 44 | 45 | if assert.NoError(t, err) { 46 | assert.NotEqual(t, (io.Writer)(nil), w) 47 | } 48 | } 49 | 50 | func TestSyslogLibNewError(t *testing.T) { 51 | s := MockSyslogLib{Err: errors.New("syslog error")} 52 | 53 | _, err := s.New() 54 | 55 | if assert.Error(t, err) { 56 | assert.Equal(t, "syslog error", err.Error()) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /internal/management/helper_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package management 31 | 32 | import ( 33 | "github.com/lets-fiware/ngsi-go/internal/helper" 34 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 35 | ) 36 | 37 | func setupTest(args []string) *ngsicli.Context { 38 | return helper.SetupTest(NewNgsiApp(), args) 39 | } 40 | 41 | func setupTestWithConfig(args []string, config string) *ngsicli.Context { 42 | return helper.SetupTestWithConfig(NewNgsiApp(), args, config) 43 | } 44 | 45 | func setupTestWithConfigAndCache(args []string, config, cache string) *ngsicli.Context { 46 | return helper.SetupTestWithConfigAndCache(NewNgsiApp(), args, config, cache) 47 | } 48 | -------------------------------------------------------------------------------- /e2e/server/oauth/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM golang:1.20.6-alpine3.18 AS builder 28 | LABEL stage=ngsi-builder 29 | 30 | WORKDIR /opt/oauth/ 31 | 32 | COPY ./main.go /opt/oauth 33 | 34 | RUN \ 35 | sed -n -e '/^nobody/p' /etc/passwd > /opt/passwd && \ 36 | chmod 444 /opt/passwd && \ 37 | GO111MODULE=off CGO_ENABLED=0 go build -ldflags "-w -s" 38 | 39 | FROM scratch AS runner 40 | LABEL stage=ngsi-runner 41 | 42 | COPY --from=builder /opt/oauth/oauth /opt/oauth/ 43 | COPY --from=builder /opt/passwd /etc/passwd 44 | 45 | WORKDIR /opt/oauth/ 46 | 47 | USER nobody 48 | 49 | EXPOSE 8000 50 | 51 | ENTRYPOINT ["/opt/oauth/oauth"] 52 | -------------------------------------------------------------------------------- /internal/ngsilib/filepathlib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import "path/filepath" 33 | 34 | // FilePathLib is ... 35 | type FilePathLib interface { 36 | FilePathAbs(path string) (string, error) 37 | FilePathJoin(elem ...string) string 38 | FilePathBase(path string) string 39 | } 40 | 41 | type filePathLib struct { 42 | } 43 | 44 | func (i *filePathLib) FilePathAbs(path string) (string, error) { 45 | return filepath.Abs(path) 46 | } 47 | 48 | func (i *filePathLib) FilePathJoin(elem ...string) string { 49 | return filepath.Join(elem...) 50 | } 51 | 52 | func (i *filePathLib) FilePathBase(path string) string { 53 | return filepath.Base(path) 54 | } 55 | -------------------------------------------------------------------------------- /extras/keycloak/nginx.conf: -------------------------------------------------------------------------------- 1 | load_module modules/ngx_http_js_module.so; 2 | 3 | user nginx; 4 | worker_processes 1; 5 | 6 | events { 7 | worker_connections 1024; 8 | } 9 | 10 | http { 11 | include /etc/nginx/mime.types; 12 | 13 | js_include keycloak_oauth2.js; 14 | 15 | map $http_authorization $token { 16 | ~^Bearer\s+(\S+)$ $1; 17 | } 18 | 19 | server { 20 | listen 1026; 21 | 22 | location / { 23 | auth_request /_token_introspection; 24 | 25 | proxy_pass http://orion:1026; 26 | proxy_set_header Host $host; 27 | proxy_set_header X-Real-IP $remote_addr; 28 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 29 | } 30 | 31 | location = /_token_introspection { 32 | internal; 33 | js_content introspectAccessToken; 34 | } 35 | 36 | location = /_request_introspection { 37 | internal; 38 | proxy_method POST; 39 | proxy_set_header Host $host; 40 | proxy_set_header X-Real-IP $remote_addr; 41 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 42 | proxy_set_header Content-Type "application/x-www-form-urlencoded"; 43 | proxy_set_header Authorization "Basic bmdzaV9hcGk6OGViNWQwMWQtZDE1NS00YjczLTk0MTQtYTNjMjhlZTRhYmE2"; 44 | proxy_set_body "token=$token"; 45 | proxy_pass http://keycloak:8080/auth/realms/fiware_service/protocol/openid-connect/token/introspect; 46 | } 47 | } 48 | 49 | server { 50 | listen 80; 51 | 52 | location / { 53 | proxy_pass http://keycloak:8080; 54 | proxy_set_header Host $host; 55 | proxy_set_header X-Real-IP $remote_addr; 56 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /internal/convenience/debug_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package convenience 31 | 32 | import ( 33 | "testing" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/assert" 36 | "github.com/lets-fiware/ngsi-go/internal/helper" 37 | ) 38 | 39 | func TestDebugCommand(t *testing.T) { 40 | c := setupTest([]string{"debug", "--host", "orion"}) 41 | 42 | err := debugCommand(c, c.Ngsi, c.Client) 43 | 44 | if assert.NoError(t, err) { 45 | actual := helper.GetStdoutString(c) 46 | expected := "config file: /fiware/ngsi-go-config.json\ncache file: /fiware/ngsi-go-token-cache.json\nHost: \"orion\"\nTenant: \"\"\nScope: \"\"\n" 47 | assert.Equal(t, expected, actual) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /e2e/server/accumulator/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM golang:1.20.6-alpine3.18 AS builder 28 | LABEL stage=ngsi-builder 29 | 30 | WORKDIR /opt/accumulator 31 | 32 | COPY ./main.go /opt/accumulator 33 | 34 | RUN \ 35 | sed -n -e '/^nobody/p' /etc/passwd > /opt/passwd && \ 36 | chmod 444 /opt/passwd && \ 37 | GO111MODULE=off CGO_ENABLED=0 go build -ldflags "-w -s" 38 | 39 | FROM scratch AS runner 40 | LABEL stage=ngsi-runner 41 | 42 | COPY --from=builder /opt/accumulator/accumulator /opt/accumulator/ 43 | COPY --from=builder /opt/passwd /etc/passwd 44 | 45 | USER nobody 46 | 47 | EXPOSE 8000 48 | 49 | ENTRYPOINT ["/opt/accumulator/accumulator"] 50 | -------------------------------------------------------------------------------- /e2e/server/csource/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM golang:1.20.6-alpine3.18 AS builder 28 | LABEL stage=ngsi-builder 29 | 30 | WORKDIR /opt/csource/ 31 | 32 | COPY ./main.go /opt/csource 33 | 34 | RUN \ 35 | sed -n -e '/^nobody/p' /etc/passwd > /opt/passwd && \ 36 | chmod 444 /opt/passwd && \ 37 | GO111MODULE=off CGO_ENABLED=0 go build -ldflags "-w -s" 38 | 39 | FROM scratch AS runner 40 | LABEL stage=ngsi-runner 41 | 42 | COPY --from=builder /opt/csource/csource /opt/csource/ 43 | COPY --from=builder /opt/passwd /etc/passwd 44 | 45 | WORKDIR /opt/csource/ 46 | 47 | USER nobody 48 | 49 | EXPOSE 8000 50 | 51 | ENTRYPOINT ["/opt/csource/csource"] 52 | -------------------------------------------------------------------------------- /e2e/server/atcontext/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM golang:1.20.6-alpine3.18 AS builder 28 | LABEL stage=ngsi-builder 29 | 30 | WORKDIR /opt/atcontext/ 31 | 32 | COPY ./main.go /opt/atcontext 33 | 34 | RUN \ 35 | sed -n -e '/^nobody/p' /etc/passwd > /opt/passwd && \ 36 | chmod 444 /opt/passwd && \ 37 | GO111MODULE=off CGO_ENABLED=0 go build -ldflags "-w -s" 38 | 39 | FROM scratch AS runner 40 | LABEL stage=ngsi-runner 41 | 42 | COPY --from=builder /opt/atcontext/atcontext /opt/atcontext/ 43 | COPY --from=builder /opt/passwd /etc/passwd 44 | 45 | WORKDIR /opt/atcontext/ 46 | 47 | USER nobody 48 | 49 | EXPOSE 8000 50 | 51 | ENTRYPOINT ["/opt/atcontext/atcontext"] 52 | -------------------------------------------------------------------------------- /internal/helper/net_lib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "net" 34 | "net/http" 35 | ) 36 | 37 | type MockNetLib struct { 38 | AddrErr error 39 | ListenAndServeErr error 40 | ListenAndServeTLSErr error 41 | } 42 | 43 | func (n *MockNetLib) InterfaceAddrs() ([]net.Addr, error) { 44 | if n.AddrErr != nil { 45 | return nil, n.AddrErr 46 | } 47 | return net.InterfaceAddrs() 48 | } 49 | 50 | func (n *MockNetLib) ListenAndServe(addr string, handler http.Handler) error { 51 | return n.ListenAndServeErr 52 | } 53 | 54 | func (n *MockNetLib) ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error { 55 | return n.ListenAndServeTLSErr 56 | } 57 | -------------------------------------------------------------------------------- /internal/convenience/debug.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package convenience 31 | 32 | import ( 33 | "fmt" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 36 | "github.com/lets-fiware/ngsi-go/internal/ngsilib" 37 | ) 38 | 39 | func debugCommand(c *ngsicli.Context, ngsi *ngsilib.NGSI, client *ngsilib.Client) error { 40 | fmt.Fprintf(ngsi.StdWriter, "config file: %s\n", *ngsi.ConfigFile.FileName()) 41 | fmt.Fprintf(ngsi.StdWriter, "cache file: %s\n", *ngsi.CacheFile.FileName()) 42 | 43 | fmt.Fprintf(ngsi.StdWriter, "Host: \"%s\"\n", ngsi.Host) 44 | fmt.Fprintf(ngsi.StdWriter, "Tenant: \"%s\"\n", client.Tenant) 45 | fmt.Fprintf(ngsi.StdWriter, "Scope: \"%s\"\n", client.Scope) 46 | 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /e2e/cases/1000_common/1001_stderr.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 --stderr info 29 | # 30 | ngsi --stderr info version --host unknown 31 | 32 | ```1 33 | REGEX(.*) 34 | Run001 error host: unknown 35 | ngsiRun005 error host: unknown 36 | newClient001 error host: unknown 37 | newClient002 error host: unknown 38 | NewClient005 error host: unknown 39 | abnormal termination 40 | ``` 41 | 42 | # 43 | # 0002 --stderr err 44 | # 45 | ngsi --stderr err version --host unknown 46 | 47 | ```1 48 | Run001 error host: unknown 49 | ``` 50 | 51 | # 52 | # 0003 settings clear 53 | # 54 | ngsi settings clear 55 | 56 | ``` 57 | ``` 58 | 59 | # 60 | # 0004 settings list 61 | # 62 | ngsi settings list 63 | 64 | ``` 65 | ``` 66 | -------------------------------------------------------------------------------- /internal/ngsilib/netlib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "testing" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/assert" 36 | ) 37 | 38 | func TestNewNetLib(t *testing.T) { 39 | acutal := NewNetLib() 40 | 41 | assert.NotEqual(t, nil, acutal) 42 | } 43 | 44 | func TestInterfaceAddrs(t *testing.T) { 45 | n := &netLib{} 46 | _, err := n.InterfaceAddrs() 47 | 48 | assert.NoError(t, err) 49 | } 50 | 51 | func TestListenAndServe(t *testing.T) { 52 | n := &netLib{} 53 | err := n.ListenAndServe("", nil) 54 | 55 | assert.Error(t, err) 56 | } 57 | func TestListenAndServeTLS(t *testing.T) { 58 | n := &netLib{} 59 | err := n.ListenAndServeTLS("", "", "", nil) 60 | assert.Error(t, err) 61 | } 62 | -------------------------------------------------------------------------------- /internal/helper/multipart_lib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "io" 34 | "mime/multipart" 35 | "net/textproto" 36 | ) 37 | 38 | type MockMultiPartLib struct { 39 | CreatePartErr error 40 | CloseErr error 41 | Mw *multipart.Writer 42 | } 43 | 44 | func (m MockMultiPartLib) CreatePart(header textproto.MIMEHeader) (io.Writer, error) { 45 | if m.CreatePartErr != nil { 46 | return nil, m.CreatePartErr 47 | } 48 | return m.Mw.CreatePart(header) 49 | } 50 | 51 | func (m MockMultiPartLib) FormDataContentType() string { 52 | return m.Mw.FormDataContentType() 53 | } 54 | 55 | func (m MockMultiPartLib) Close() error { 56 | if m.CloseErr != nil { 57 | return m.CloseErr 58 | } 59 | return m.Mw.Close() 60 | } 61 | -------------------------------------------------------------------------------- /script/lint-dockerfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # MIT License 4 | # 5 | # Copyright (c) 2020-2024 Kazuhito Suda 6 | # 7 | # This file is part of NGSI Go 8 | # 9 | # https://github.com/lets-fiware/ngsi-go 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documentation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in all 19 | # copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | # SOFTWARE. 28 | 29 | set -e 30 | 31 | if [ -e lint-dockerfile.sh ]; then 32 | cd .. 33 | fi 34 | 35 | docker pull hadolint/hadolint 36 | docker run --rm -i hadolint/hadolint < docker/Dockerfile 37 | docker run --rm -i hadolint/hadolint < e2e/ngsi-test/Dockerfile 38 | docker run --rm -i hadolint/hadolint < e2e/server/accumulator/Dockerfile 39 | docker run --rm -i hadolint/hadolint < e2e/server/atcontext/Dockerfile 40 | docker run --rm -i hadolint/hadolint < e2e/server/csource/Dockerfile 41 | docker run --rm -i hadolint/hadolint < e2e/server/oauth/Dockerfile 42 | docker run --rm -i hadolint/hadolint < tools/mdlint/Dockerfile 43 | docker run --rm -i hadolint/hadolint < tools/textlint/Dockerfile 44 | -------------------------------------------------------------------------------- /e2e/cases/6500_keyrock/0010_version.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 Keyrock version 29 | # 30 | ngsi version --host keyrock 31 | 32 | ``` 33 | {"keyrock":{"version":"8.3.0","release_date":"2023-06-09T13:19:25.000Z","uptime":"REGEX(.*)","doc":"https://keyrock-fiware.github.io/","api":{"version":"v1","link":"http://localhost:3000/v1"}}} 34 | ``` 35 | 36 | # 37 | # 0002 Keyrock version --pretty 38 | # 39 | ngsi version --host keyrock --pretty 40 | 41 | ``` 42 | { 43 | "keyrock": { 44 | "version": "8.3.0", 45 | "release_date": "2023-06-09T13:19:25.000Z", 46 | "uptime": "REGEX(.*)", 47 | "doc": "https://keyrock-fiware.github.io/", 48 | "api": { 49 | "version": "v1", 50 | "link": "http://localhost:3000/v1" 51 | } 52 | } 53 | } 54 | ``` 55 | -------------------------------------------------------------------------------- /internal/ngsilib/ioutillib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "bytes" 34 | "io" 35 | "testing" 36 | ) 37 | 38 | func TestIoutilLibCopy(t *testing.T) { 39 | iolib := ioutilLib{} 40 | src := bytes.NewReader([]byte("FIWARE")) 41 | 42 | _, _ = iolib.Copy(io.Discard, src) 43 | } 44 | 45 | func TestIoutilLibReadFull(t *testing.T) { 46 | iolib := ioutilLib{} 47 | src := bytes.NewReader([]byte("FIWARE")) 48 | buf := make([]byte, 10) 49 | 50 | _, _ = iolib.ReadFull(src, buf) 51 | } 52 | 53 | func TestIoutilLibWriteFile(t *testing.T) { 54 | iolib := ioutilLib{} 55 | buf := make([]byte, 10) 56 | 57 | _ = iolib.WriteFile("", buf, 0644) 58 | } 59 | 60 | func TestIoutilLibReadFile(t *testing.T) { 61 | iolib := ioutilLib{} 62 | 63 | _, _ = iolib.ReadFile("") 64 | } 65 | -------------------------------------------------------------------------------- /extras/queryproxy/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM golang:1.20.6-alpine3.18 AS builder 28 | 29 | RUN \ 30 | cd / && \ 31 | apk update && \ 32 | apk add --no-cache git make && \ 33 | git clone https://github.com/lets-fiware/ngsi-go.git && \ 34 | cd /ngsi-go && \ 35 | make bin/ngsi 36 | 37 | 38 | FROM alpine:3.15 AS runner 39 | 40 | COPY --from=builder /ngsi-go/bin/ngsi /usr/local/bin/ngsi 41 | COPY ./ngsi-go-config.json /opt/ngsi-go/ngsi-go-config.json 42 | 43 | WORKDIR /opt/ngsi-go/ 44 | 45 | RUN chown -R nobody:nobody /opt/ngsi-go 46 | 47 | USER nobody 48 | 49 | ENTRYPOINT ["/usr/local/bin/ngsi"] 50 | CMD ["--stderr", "info", "--config", "./ngsi-go-config.json", "--cache", "./ngsi-go-token-cache.json", "queryproxy", "server", "--host", "orion", "--verbose"] 51 | -------------------------------------------------------------------------------- /e2e/cases/6200_perseo/0003_perseo_admin_log.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 ngsi admin --host perseo log --pretty 29 | # 30 | ngsi admin --host perseo log --pretty 31 | 32 | ``` 33 | { 34 | "level": "INFO" 35 | } 36 | ``` 37 | 38 | # 39 | # 0002 ngsi admin log --level DEBUG 40 | # 41 | ngsi admin log --level DEBUG 42 | 43 | ``` 44 | ``` 45 | 46 | # 47 | # 0003 ngsi admin --host perseo log --pretty 48 | # 49 | ngsi admin --host perseo log --pretty 50 | 51 | ``` 52 | { 53 | "level": "DEBUG" 54 | } 55 | ``` 56 | 57 | # 58 | # 0004 ngsi admin log --level INFO 59 | # 60 | ngsi admin log --level info 61 | 62 | ``` 63 | ``` 64 | 65 | # 66 | # 0005 ngsi admin --host perseo log --pretty 67 | # 68 | ngsi admin --host perseo log --pretty 69 | 70 | ``` 71 | { 72 | "level": "INFO" 73 | } 74 | ``` 75 | -------------------------------------------------------------------------------- /extras/registration_proxy/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM golang:1.20.6-alpine3.18 AS builder 28 | 29 | RUN \ 30 | cd / && \ 31 | apk update && \ 32 | apk add --no-cache git make && \ 33 | git clone https://github.com/lets-fiware/ngsi-go.git && \ 34 | cd /ngsi-go && \ 35 | make bin/ngsi 36 | 37 | 38 | FROM alpine:3.15 AS runner 39 | 40 | COPY --from=builder /ngsi-go/bin/ngsi /usr/local/bin/ngsi 41 | COPY ./ngsi-go-config.json /opt/ngsi-go/ngsi-go-config.json 42 | 43 | WORKDIR /opt/ngsi-go/ 44 | 45 | RUN chown -R nobody:nobody /opt/ngsi-go 46 | 47 | USER nobody 48 | 49 | ENTRYPOINT ["/usr/local/bin/ngsi"] 50 | CMD ["--stderr", "info", "--config", "./ngsi-go-config.json", "--cache", "./ngsi-go-token-cache.json", "regproxy", "server", "--host", "remote-orion", "--verbose"] 51 | -------------------------------------------------------------------------------- /roadmap.md: -------------------------------------------------------------------------------- 1 | # NGSI Go Roadmap 2 | 3 | This product is a FIWARE related software. If you would like to learn about the 4 | overall Roadmap of FIWARE, please check section "Roadmap" on the 5 | [FIWARE Catalogue](https://github.com/Fiware/catalogue). 6 | 7 | ## Introduction 8 | 9 | This section elaborates on proposed new features or tasks which are expected to 10 | be added to the product in the foreseeable future. There should be no assumption 11 | of a commitment to deliver these features on specific dates or in the order 12 | given. The development team will be doing their best to follow the proposed 13 | dates and priorities, but please bear in mind that plans to work on a given 14 | feature or task may be revised. All information is provided as a general 15 | guidelines only, and this section may be revised to provide newer information at 16 | any time. 17 | 18 | ## Short term 19 | 20 | The following list of features are planned to be addressed in the short term, 21 | and incorporated in the next release of the product planned for March 2022: 22 | 23 | - Improve NGSI commands and convenience commands 24 | - NGSI-LD API support 25 | - Improve unit tests and E2E tests 26 | 27 | ## Medium term 28 | 29 | The following list of features are planned to be addressed in the medium term, 30 | typically within the subsequent release(s) generated in the next 9 months after 31 | next planned release: 32 | 33 | - NGSI-LD API full support ([ETSI GS CIM 009 v1.4.2](https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.04.02_60/gs_CIM009v010402p.pdf)) 34 | - NGSI-LD API full support ([ETSI GS CIM 009 v1.5.1](https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.05.01_60/gs_CIM009v010501p.pdf)) 35 | 36 | ## Long term 37 | 38 | The following list of features are proposals regarding the longer-term evolution 39 | of the product even though development of these features has not yet been 40 | scheduled for a release in the near future. Please feel free to contact us if 41 | you wish to get involved in the implementation or influence the roadmap 42 | 43 | - FIWARE Incubated GE 44 | -------------------------------------------------------------------------------- /internal/helper/zip_lib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "archive/zip" 34 | "io" 35 | "mime/multipart" 36 | 37 | "github.com/lets-fiware/ngsi-go/internal/ngsilib" 38 | ) 39 | 40 | type MockZipLib struct { 41 | Zip error 42 | ZipReader *zip.Reader 43 | } 44 | 45 | func (z *MockZipLib) NewReader(r io.ReaderAt, size int64) (*zip.Reader, error) { 46 | if z.Zip != nil { 47 | return nil, z.Zip 48 | } 49 | if z.ZipReader != nil { 50 | return z.ZipReader, nil 51 | } 52 | return zip.NewReader(r, size) 53 | } 54 | 55 | type MockMultiPart struct { 56 | CreatePartErr error 57 | CloseErr error 58 | } 59 | 60 | func (m *MockMultiPart) NewWriter(w io.Writer) ngsilib.MultiPartLib { 61 | return &MockMultiPartLib{Mw: multipart.NewWriter(w), CreatePartErr: m.CreatePartErr, CloseErr: m.CloseErr} 62 | } 63 | -------------------------------------------------------------------------------- /internal/ngsilib/multipartlib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "bytes" 34 | "net/textproto" 35 | "os" 36 | "testing" 37 | 38 | "github.com/lets-fiware/ngsi-go/internal/assert" 39 | ) 40 | 41 | func TestMultiPart(t *testing.T) { 42 | mp := &multiPart{} 43 | 44 | w := mp.NewWriter(os.Stdout) 45 | 46 | assert.NotEqual(t, nil, w) 47 | } 48 | 49 | func TestMultiPartLibNewWriter(t *testing.T) { 50 | var body bytes.Buffer 51 | 52 | mp := &multiPart{} 53 | m := mp.NewWriter(&body) 54 | mh := make(textproto.MIMEHeader) 55 | mh.Set("Content-Type", "application/octet-stream") 56 | mh.Set("Content-Disposition", "form-data; name=\"file\"; filename=\"test\"") 57 | _, err := m.CreatePart(mh) 58 | assert.NoError(t, err) 59 | _ = m.FormDataContentType() 60 | err = m.Close() 61 | assert.NoError(t, err) 62 | } 63 | -------------------------------------------------------------------------------- /e2e/cases/0000_prepare/0001_wait_for_services.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 wait for services 29 | # 30 | wait ${accumulator}/health 31 | wait ${atcontext}/health 32 | wait ${csource}/health 33 | wait ${oauth}/health 34 | wait ${orion}/version 35 | wait ${orion-ld}/version 36 | wait ${quantumleap}/version 37 | wait ${comet}/version 38 | wait ${iota}/iot/about 39 | wait ${perseo}/version 40 | wait ${perseo-core}/perseo-core/version 41 | wait ${cygnus}/v1/version 42 | wait ${wirecloud}/api/features 43 | 44 | # 45 | # 0002 check quantumleap health status 46 | # 47 | wait ${quantumleap}/health --retry 600 --status pass 48 | 49 | # 50 | # 0003 check Keyrock 51 | # 52 | wait ${keyrock}/oauth2/token --retry 600 --verb POST --statuscode 400 53 | 54 | # 55 | # 0003 check Wilma 56 | # 57 | wait ${pep-proxy}/version --retry 600 --statuscode 401 58 | -------------------------------------------------------------------------------- /extras/tokenproxy/Dockerfile: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | FROM golang:1.20.6-alpine3.18 AS builder 28 | 29 | RUN \ 30 | cd / && \ 31 | apk update && \ 32 | apk add --no-cache git make && \ 33 | git clone https://github.com/lets-fiware/ngsi-go.git && \ 34 | cd /ngsi-go && \ 35 | make bin/ngsi 36 | 37 | 38 | FROM alpine:3.15 AS runner 39 | 40 | COPY --from=builder /ngsi-go/bin/ngsi /usr/local/bin/ngsi 41 | 42 | WORKDIR /opt/ngsi-go/ 43 | 44 | RUN chown -R nobody:nobody /opt/ngsi-go 45 | 46 | USER nobody 47 | 48 | ENTRYPOINT ["/usr/local/bin/ngsi"] 49 | CMD ["--stderr", "info", "--config", "./ngsi-go-config.json", "--cache", "./ngsi-go-token-cache.json", "tokenproxy", "server", "--idmHost", "http://keyrock:3000", "--clientId", "a1a6048b-df1d-4d4f-9a08-5cf836041d14", "--clientSecret", "e4cc0147-e38f-4211-b8ad-8ae5e6a107f9", "--verbose"] 50 | -------------------------------------------------------------------------------- /internal/helper/filepath_lib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "errors" 34 | "testing" 35 | 36 | "github.com/lets-fiware/ngsi-go/internal/assert" 37 | ) 38 | 39 | func TestFilePathFilePathAbs(t *testing.T) { 40 | m := &MockFilePathLib{PathAbsErr: errors.New("FilePatLib error")} 41 | 42 | s, err := m.FilePathAbs("fiware") 43 | 44 | if assert.Error(t, err) { 45 | assert.Equal(t, "FilePatLib error", err.Error()) 46 | assert.Equal(t, "fiware", s) 47 | } 48 | } 49 | 50 | func TestFilePathFilePathJoin(t *testing.T) { 51 | m := &MockFilePathLib{} 52 | 53 | s := m.FilePathJoin("ngsi-ld", "v1") 54 | 55 | assert.Equal(t, "ngsi-ld/v1", s) 56 | } 57 | 58 | func TestFilePathFilePathBase(t *testing.T) { 59 | m := &MockFilePathLib{} 60 | 61 | s := m.FilePathBase("/ngsi-ld/v1/entities") 62 | 63 | assert.Equal(t, "entities", s) 64 | } 65 | -------------------------------------------------------------------------------- /internal/helper/time_lib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package helper 31 | 32 | import ( 33 | "time" 34 | ) 35 | 36 | type MockTimeLib struct { 37 | DateTime string 38 | UnixTime int64 39 | TimeFormat *string 40 | TTime *time.Time 41 | } 42 | 43 | func (t *MockTimeLib) Now() time.Time { 44 | layout := "2006-01-02T15:04:05.000Z" 45 | tm, _ := time.Parse(layout, t.DateTime) 46 | return tm 47 | } 48 | 49 | func (t *MockTimeLib) NowUnix() int64 { 50 | return t.UnixTime + time.Now().Unix() 51 | } 52 | 53 | func (t *MockTimeLib) Unix(sec int64, nsec int64) time.Time { 54 | if t.TTime != nil { 55 | return *t.TTime 56 | } 57 | tt := time.Unix(sec, nsec) 58 | t.TTime = &tt 59 | return tt 60 | } 61 | 62 | func (t *MockTimeLib) Format(layout string) string { 63 | if t.TimeFormat != nil { 64 | return *t.TimeFormat 65 | } 66 | return t.TTime.Format(layout) 67 | } 68 | -------------------------------------------------------------------------------- /internal/ngsicli/token.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsicli 31 | 32 | type token struct { 33 | args []string 34 | cur int 35 | len int 36 | } 37 | 38 | func newToken(args []string) *token { 39 | return &token{args: args, len: len(args)} 40 | } 41 | 42 | func (t *token) Next() *string { 43 | if t.cur >= t.len { 44 | t.cur += 1 45 | if t.cur > t.len+1 { 46 | t.cur = t.len + 1 47 | } 48 | return nil 49 | } 50 | arg := t.args[t.cur] 51 | t.cur += 1 52 | 53 | return &arg 54 | } 55 | 56 | func (t *token) Peek() *string { 57 | if t.cur >= t.len { 58 | return nil 59 | } 60 | arg := t.args[t.cur] 61 | 62 | return &arg 63 | } 64 | 65 | func (t *token) Prev() *string { 66 | t.cur -= 1 67 | if t.cur < 0 { 68 | t.cur = 0 69 | return nil 70 | } 71 | if t.cur >= t.len { 72 | return nil 73 | } 74 | arg := t.args[t.cur] 75 | 76 | return &arg 77 | } 78 | -------------------------------------------------------------------------------- /internal/ngsilib/netlib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "net" 34 | "net/http" 35 | ) 36 | 37 | // NetLib is ... 38 | type NetLib interface { 39 | InterfaceAddrs() ([]net.Addr, error) 40 | ListenAndServe(addr string, handler http.Handler) error 41 | ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error 42 | } 43 | 44 | func NewNetLib() *netLib { 45 | return &netLib{} 46 | } 47 | 48 | type netLib struct { 49 | } 50 | 51 | func (n *netLib) InterfaceAddrs() ([]net.Addr, error) { 52 | return net.InterfaceAddrs() 53 | } 54 | 55 | func (n *netLib) ListenAndServe(addr string, handler http.Handler) error { 56 | return http.ListenAndServe(addr, handler) 57 | } 58 | func (n *netLib) ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error { 59 | return http.ListenAndServeTLS(addr, certFile, keyFile, handler) 60 | } 61 | -------------------------------------------------------------------------------- /internal/ngsicli/args_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsicli 31 | 32 | import ( 33 | "testing" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/assert" 36 | ) 37 | 38 | func TestArgsGet(t *testing.T) { 39 | 40 | cmdArgs := cmdArgs{"orion", "iota", "wirecloud", "cygnus", "comet"} 41 | 42 | assert.Equal(t, "orion", cmdArgs.Get(0)) 43 | assert.Equal(t, "iota", cmdArgs.Get(1)) 44 | assert.Equal(t, "wirecloud", cmdArgs.Get(2)) 45 | assert.Equal(t, "cygnus", cmdArgs.Get(3)) 46 | assert.Equal(t, "comet", cmdArgs.Get(4)) 47 | } 48 | 49 | func TestArgsGetError(t *testing.T) { 50 | 51 | cmdArgs := cmdArgs{"orion", "iota", "wirecloud", "cygnus", "comet"} 52 | 53 | assert.Equal(t, "", cmdArgs.Get(-1)) 54 | assert.Equal(t, "", cmdArgs.Get(5)) 55 | } 56 | 57 | func TestArgsLen(t *testing.T) { 58 | 59 | cmdArgs := cmdArgs{"orion", "iota", "wirecloud", "cygnus", "comet"} 60 | 61 | assert.Equal(t, 5, cmdArgs.Len()) 62 | } 63 | -------------------------------------------------------------------------------- /e2e/cases/4000_ngsi-v2/9003_subs_only_uri.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | # 27 | 28 | # 29 | # 0001 Create subscription --uri 30 | # 31 | ngsi create --host orion subscription --uri http://localhost:1026 32 | 33 | ``` 34 | REGEX(.*) 35 | ``` 36 | 37 | # 38 | # 0002 Save subscription id 39 | # 40 | $id=$$ 41 | 42 | # 43 | # 0003 Get subscription 44 | # 45 | ngsi get subscription --id $id --pretty 46 | 47 | ``` 48 | { 49 | "id": "REGEX(.*)", 50 | "subject": { 51 | "entities": [ 52 | { 53 | "idPattern": ".*" 54 | } 55 | ], 56 | "condition": {} 57 | }, 58 | "notification": { 59 | "onlyChangedAttrs": false, 60 | "http": { 61 | "url": "http://localhost:1026" 62 | }, 63 | "attrsFormat": "normalized" 64 | }, 65 | "status": "active" 66 | } 67 | ``` 68 | 69 | # 70 | # 9999 Delete subscription 71 | # 72 | ngsi delete --host orion subscription --id $id 73 | 74 | ``` 75 | ``` 76 | -------------------------------------------------------------------------------- /internal/convenience/documents.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package convenience 31 | 32 | import ( 33 | "fmt" 34 | 35 | "github.com/lets-fiware/ngsi-go/internal/ngsicli" 36 | "github.com/lets-fiware/ngsi-go/internal/ngsilib" 37 | ) 38 | 39 | func documents(c *ngsicli.Context, ngsi *ngsilib.NGSI, client *ngsilib.Client) error { 40 | fmt.Fprintln(ngsi.StdWriter, "English:") 41 | fmt.Fprintln(ngsi.StdWriter, " https://fiware-orion.readthedocs.io/") 42 | fmt.Fprintln(ngsi.StdWriter, " https://telefonicaid.github.io/fiware-orion/api/v2/stable/") 43 | fmt.Fprintln(ngsi.StdWriter, " https://ngsi-go.letsfiware.jp/") 44 | fmt.Fprintln(ngsi.StdWriter, "Japanese:") 45 | fmt.Fprintln(ngsi.StdWriter, " https://fiware-orion.letsfiware.jp/") 46 | fmt.Fprintln(ngsi.StdWriter, " https://open-apis.letsfiware.jp/fiware-orion/api/v2/stable/") 47 | fmt.Fprintln(ngsi.StdWriter, " https://open-apis.letsfiware.jp/keyrock/") 48 | 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /extras/basic_authentication/README.md: -------------------------------------------------------------------------------- 1 | # Access a broker with Basic authentication 2 | 3 | This documentation describes how to access an Orion Context Broker that the endpoints of NGSI API 4 | are protected by Basic Authentication. 5 | 6 | ## Prepare 7 | 8 | Clone the NGSI Go repository and move to `ngsi-go/extras/basic_authentication` directory. 9 | 10 | ``` 11 | git clone https://github.com/lets-fiware/ngsi-go.git 12 | cd ngsi-go/extras/basic_authentication 13 | ``` 14 | 15 | ## Add user 16 | 17 | Add username and password to the htpasswd file. 18 | 19 | ``` 20 | NAME=fiware PASS='1234'; echo $NAME:`openssl passwd -6 $PASS` >> htpasswd 21 | ``` 22 | 23 | ## Start up 24 | 25 | Start up an Orion context broker. 26 | 27 | ``` 28 | docker-compose up -d 29 | ``` 30 | 31 | You can see three containers. 32 | 33 | ``` 34 | Name Command State Ports 35 | -------------------------------------------------------------------------------------------------------- 36 | basic_authentication_mongo_1 docker-entrypoint.sh --noj ... Up 27017/tcp 37 | basic_authentication_nginx_1 /docker-entrypoint.sh ngin ... Up 0.0.0.0:80->80/tcp,:::80->80/tcp 38 | basic_authentication_orion_1 /usr/bin/contextBroker -fg ... Up 1026/tcp 39 | ``` 40 | 41 | ### Sanity check 42 | 43 | Check the service is ready by executing the following command. 44 | 45 | ``` 46 | curl localhost:1026/version 47 | ``` 48 | 49 | ``` 50 | 51 | 401 Authorization Required 52 | 53 |

401 Authorization Required

54 |
nginx/1.19.10
55 | 56 | 57 | ``` 58 | 59 | 60 | ## Add the broker 61 | 62 | Add the broker to NGSI Go configuration. 63 | 64 | ``` 65 | ngsi broker add \ 66 | --host orion-with-basic-auth \ 67 | --ngsiType v2 \ 68 | --brokerHost http://localhost:1026/ \ 69 | --idmType basic \ 70 | --username fiware \ 71 | --password 1234 72 | ``` 73 | 74 | ## Access the broker 75 | 76 | The following command allows you to access the broker with Basic authentication. 77 | 78 | ``` 79 | ngsi version --host orion-with-basic-auth 80 | ``` 81 | -------------------------------------------------------------------------------- /internal/ngsilib/ioutillib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "io" 34 | "os" 35 | ) 36 | 37 | // IoutilLib is ... 38 | type IoutilLib interface { 39 | Copy(dst io.Writer, src io.Reader) (int64, error) 40 | ReadFull(r io.Reader, buf []byte) (n int, err error) 41 | WriteFile(filename string, data []byte, perm os.FileMode) error 42 | ReadFile(filename string) ([]byte, error) 43 | } 44 | 45 | type ioutilLib struct { 46 | } 47 | 48 | func (i *ioutilLib) Copy(dst io.Writer, src io.Reader) (int64, error) { 49 | return io.Copy(dst, src) 50 | } 51 | 52 | func (i *ioutilLib) ReadFull(r io.Reader, buf []byte) (n int, err error) { 53 | return io.ReadFull(r, buf) 54 | } 55 | 56 | func (i *ioutilLib) WriteFile(filename string, data []byte, perm os.FileMode) error { 57 | return os.WriteFile(filename, data, perm) 58 | } 59 | 60 | func (i *ioutilLib) ReadFile(filename string) ([]byte, error) { 61 | return os.ReadFile(filename) 62 | } 63 | -------------------------------------------------------------------------------- /.github/workflows/cla.yml: -------------------------------------------------------------------------------- 1 | name: "CLA Assistant" 2 | on: 3 | issue_comment: 4 | types: [created] 5 | pull_request_target: 6 | types: [opened,closed,synchronize] 7 | 8 | jobs: 9 | CLAssistant: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: "CLA Assistant" 13 | if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' 14 | uses: cla-assistant/github-action@v2.1.1-beta 15 | env: 16 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 17 | # the below token should have repo scope and must be manually added by you in the repository's secret 18 | PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} 19 | with: 20 | path-to-signatures: 'signatures/version1/cla.json' 21 | path-to-document: 'https://github.com/lets-fiware/ngsi-go/blob/main/ngsi-go-individual-cla.pdf' # e.g. a CLA or a DCO document 22 | # branch should not be protected 23 | branch: 'main' 24 | allowlist: fisuda,bot* 25 | use-dco-flag: false #'Set this to true if you want to use a dco instead of a cla' 26 | 27 | #below are the optional inputs - If the optional inputs are not given, then default values will be taken 28 | #remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository) 29 | #remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository) 30 | #create-file-commit-message: 'For example: Creating file for storing CLA Signatures' 31 | #signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo' 32 | #custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign' 33 | #custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.' 34 | -------------------------------------------------------------------------------- /internal/ngsilib/jsonlib.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "bytes" 34 | "encoding/json" 35 | "io" 36 | ) 37 | 38 | // JSONLib is 39 | type JSONLib interface { 40 | Decode(r io.Reader, v interface{}) error 41 | Encode(w io.Writer, v interface{}) error 42 | Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error 43 | Valid(data []byte) bool 44 | } 45 | 46 | type jsonLib struct { 47 | } 48 | 49 | func (j *jsonLib) Decode(r io.Reader, v interface{}) error { 50 | return json.NewDecoder(r).Decode(v) 51 | } 52 | 53 | func (j *jsonLib) Encode(w io.Writer, v interface{}) error { 54 | encoder := json.NewEncoder(w) 55 | encoder.SetEscapeHTML(false) 56 | return encoder.Encode(v) 57 | } 58 | 59 | func (j *jsonLib) Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error { 60 | return json.Indent(dst, src, prefix, indent) 61 | } 62 | 63 | func (j *jsonLib) Valid(data []byte) bool { 64 | return json.Valid(data) 65 | } 66 | -------------------------------------------------------------------------------- /internal/perseo/flags.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package perseo 31 | 32 | import "github.com/lets-fiware/ngsi-go/internal/ngsicli" 33 | 34 | // PERSEO FE 35 | var ( 36 | perseoRulesNameRFlag = &ngsicli.StringFlag{ 37 | Name: "name", 38 | Aliases: []string{"n"}, 39 | Usage: "rule name", 40 | Required: true, 41 | } 42 | perseoRulesDataRFlag = &ngsicli.StringFlag{ 43 | Name: "data", 44 | Aliases: []string{"d"}, 45 | Usage: "rule data", 46 | Required: true, 47 | } 48 | perseoRulesLimitFlag = &ngsicli.Int64Flag{ 49 | Name: "limit", 50 | Usage: "maximum number of rules", 51 | } 52 | perseoRulesOffsetFlag = &ngsicli.Int64Flag{ 53 | Name: "offset", 54 | Usage: "offset to skip a given number of rules at the beginning", 55 | } 56 | perseoRulesRaw = &ngsicli.BoolFlag{ 57 | Name: "raw", 58 | Usage: "print raw data", 59 | } 60 | perseoRulesCount = &ngsicli.BoolFlag{ 61 | Name: "count", 62 | Usage: "print number of rules", 63 | } 64 | ) 65 | -------------------------------------------------------------------------------- /e2e/cases/6000_time_series/2000_quantumleap/0010_hget_entities.test: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020-2024 Kazuhito Suda 4 | # 5 | # This file is part of NGSI Go 6 | # 7 | # https://github.com/lets-fiware/ngsi-go 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # 28 | # 0001 hget entities 29 | # 30 | ngsi hget entities 31 | 32 | ``` 33 | [ 34 | { 35 | "entityId": "Event001", 36 | "entityType": "Event", 37 | "index": "REGEX(.*)" 38 | }, 39 | { 40 | "entityId": "Event002", 41 | "entityType": "Event", 42 | "index": "REGEX(.*)" 43 | }, 44 | { 45 | "entityId": "device001", 46 | "entityType": "Thing", 47 | "index": "REGEX(.*)" 48 | }, 49 | { 50 | "entityId": "device002", 51 | "entityType": "Thing", 52 | "index": "REGEX(.*)" 53 | } 54 | ] 55 | ``` 56 | 57 | # 58 | # 0002 hget entities --type 59 | # 60 | ngsi hget entities --type Event 61 | 62 | ``` 63 | [ 64 | { 65 | "entityId": "Event001", 66 | "entityType": "Event", 67 | "index": "REGEX(.*)" 68 | }, 69 | { 70 | "entityId": "Event002", 71 | "entityType": "Event", 72 | "index": "REGEX(.*)" 73 | } 74 | ] 75 | ``` 76 | -------------------------------------------------------------------------------- /internal/ngsilib/jsonlib_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2024 Kazuhito Suda 5 | 6 | This file is part of NGSI Go 7 | 8 | https://github.com/lets-fiware/ngsi-go 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | package ngsilib 31 | 32 | import ( 33 | "bytes" 34 | "testing" 35 | 36 | "github.com/lets-fiware/ngsi-go/internal/assert" 37 | ) 38 | 39 | func TestJSONLibDecode(t *testing.T) { 40 | j := &jsonLib{} 41 | buf := &bytes.Buffer{} 42 | var i int 43 | err := j.Decode(buf, &i) 44 | 45 | if assert.Error(t, err) { 46 | assert.Equal(t, "EOF", err.Error()) 47 | } 48 | } 49 | 50 | func TestJSONLibEncode(t *testing.T) { 51 | j := &jsonLib{} 52 | buf := &bytes.Buffer{} 53 | var i int 54 | err := j.Encode(buf, &i) 55 | 56 | assert.NoError(t, err) 57 | } 58 | 59 | func TestIndent(t *testing.T) { 60 | j := &jsonLib{} 61 | buf := &bytes.Buffer{} 62 | src := []byte("{}") 63 | err := j.Indent(buf, src, "", " ") 64 | 65 | assert.NoError(t, err) 66 | } 67 | 68 | func TestValid(t *testing.T) { 69 | j := &jsonLib{} 70 | src := []byte("{}") 71 | actual := j.Valid(src) 72 | 73 | expected := true 74 | 75 | assert.Equal(t, expected, actual) 76 | } 77 | --------------------------------------------------------------------------------