From d8738c5ce67dc173c56fbe0923e54c48cf148fc1 Mon Sep 17 00:00:00 2001 From: Noah Botimer Date: Mon, 6 Nov 2023 11:41:04 -0500 Subject: [PATCH] Remove api and cli directories in favor of new app - Remove the API and CLI directories entirely - Remove references from GitHub workflows and replace with new app --- .github/workflows/build-cli-latest.yml | 32 - ...-api-latest.yml => build-lauth-latest.yml} | 16 +- .github/workflows/ci.yml | 23 +- api/.envrc | 1 - api/.gitignore | 35 - api/.rspec | 3 - api/.ruby-version | 1 - api/.standard.yml | 3 - api/Dockerfile | 36 - api/Dockerfile.prod | 37 - api/Gemfile | 24 - api/Gemfile.lock | 254 ------- api/LICENSE | 29 - api/README.md | 72 -- api/Rakefile | 9 - api/api.rb | 645 ------------------ api/bin/cucumber | 29 - api/bin/rackup | 29 - api/bin/rspec | 29 - api/bin/standardrb | 29 - api/config.ru | 6 - api/config/puma.rb | 3 - api/config/settings.yml | 69 -- api/cucumber.yml | 2 - .../migrate/20220810151545_create_clients.rb | 10 - api/features/authenticate.feature | 33 - api/features/crud/clients.feature | 76 --- api/features/crud/collections.feature | 111 --- api/features/crud/groups.feature | 112 --- api/features/crud/institutions.feature | 111 --- api/features/crud/networks.feature | 107 --- api/features/crud/users.feature | 113 --- api/features/query_networks.feature | 26 - .../step_definitions/clients_steps.rb | 5 - .../step_definitions/collection_steps.rb | 5 - .../step_definitions/endpoint_steps.rb | 21 - api/features/step_definitions/group_steps.rb | 5 - .../step_definitions/institution_steps.rb | 5 - .../step_definitions/network_steps.rb | 22 - api/features/step_definitions/user_steps.rb | 20 - api/features/support/env.rb | 37 - api/spec/repositories/client_spec.rb | 23 - api/spec/repositories/collection_spec.rb | 67 -- api/spec/repositories/group_spec.rb | 42 -- api/spec/repositories/institution_spec.rb | 28 - api/spec/repositories/location_spec.rb | 10 - api/spec/repositories/network_spec.rb | 207 ------ api/spec/repositories/user_spec.rb | 42 -- api/spec/spec_helper.rb | 121 ---- api/spec/yabeda/create_count_spec.rb | 52 -- api/spec/yabeda/delete_count_spec.rb | 52 -- api/spec/yabeda/index_count_spec.rb | 52 -- api/spec/yabeda/read_count_spec.rb | 52 -- api/spec/yabeda/update_count_spec.rb | 52 -- cli/.envrc | 1 - cli/.gitignore | 32 - cli/.rspec | 3 - cli/.ruby-version | 1 - cli/.standard.yml | 3 - cli/Dockerfile | 37 - cli/Dockerfile.prod | 45 -- cli/Gemfile | 20 - cli/Gemfile.lock | 194 ------ cli/LICENSE | 29 - cli/README.md | 20 - cli/app/create.rb | 152 ----- cli/app/delete.rb | 99 --- cli/app/ipv4.rb | 51 -- cli/app/list.rb | 108 --- cli/app/query.rb | 26 - cli/app/read.rb | 99 --- cli/app/update.rb | 117 ---- cli/bin/cucumber | 29 - cli/bin/lauth | 5 - cli/bin/rspec | 29 - cli/bin/standardrb | 29 - cli/cli.rb | 87 --- cli/cucumber.yml | 2 - cli/features/authorized.feature | 25 - cli/features/crud/clients.feature | 53 -- cli/features/crud/collections.feature | 63 -- cli/features/crud/groups.feature | 64 -- cli/features/crud/institutions.feature | 63 -- cli/features/crud/networks.feature | 67 -- cli/features/crud/users.feature | 64 -- cli/features/ipv4.feature | 145 ---- cli/features/query_networks.feature | 24 - cli/features/step_definitions/client_steps.rb | 5 - .../step_definitions/colection_steps.rb | 5 - cli/features/step_definitions/group_steps.rb | 5 - .../step_definitions/institution_steps.rb | 5 - cli/features/step_definitions/lauth_steps.rb | 19 - .../step_definitions/network_steps.rb | 22 - cli/features/step_definitions/user_steps.rb | 9 - cli/features/support/env.rb | 66 -- cli/lauth.rdoc | 65 -- cli/spec/api_repositories/client_spec.rb | 43 -- cli/spec/api_repositories/collection_spec.rb | 43 -- cli/spec/api_repositories/group_spec.rb | 43 -- cli/spec/api_repositories/institution_spec.rb | 43 -- cli/spec/api_repositories/network_spec.rb | 43 -- cli/spec/api_repositories/user_spec.rb | 49 -- cli/spec/spec_helper.rb | 147 ---- 103 files changed, 17 insertions(+), 5416 deletions(-) delete mode 100644 .github/workflows/build-cli-latest.yml rename .github/workflows/{build-api-latest.yml => build-lauth-latest.yml} (57%) delete mode 100644 api/.envrc delete mode 100644 api/.gitignore delete mode 100644 api/.rspec delete mode 100644 api/.ruby-version delete mode 100644 api/.standard.yml delete mode 100644 api/Dockerfile delete mode 100644 api/Dockerfile.prod delete mode 100644 api/Gemfile delete mode 100644 api/Gemfile.lock delete mode 100644 api/LICENSE delete mode 100644 api/README.md delete mode 100644 api/Rakefile delete mode 100644 api/api.rb delete mode 100755 api/bin/cucumber delete mode 100755 api/bin/rackup delete mode 100755 api/bin/rspec delete mode 100755 api/bin/standardrb delete mode 100644 api/config.ru delete mode 100644 api/config/puma.rb delete mode 100644 api/config/settings.yml delete mode 100644 api/cucumber.yml delete mode 100644 api/db/migrate/20220810151545_create_clients.rb delete mode 100644 api/features/authenticate.feature delete mode 100644 api/features/crud/clients.feature delete mode 100644 api/features/crud/collections.feature delete mode 100644 api/features/crud/groups.feature delete mode 100644 api/features/crud/institutions.feature delete mode 100644 api/features/crud/networks.feature delete mode 100644 api/features/crud/users.feature delete mode 100644 api/features/query_networks.feature delete mode 100644 api/features/step_definitions/clients_steps.rb delete mode 100644 api/features/step_definitions/collection_steps.rb delete mode 100644 api/features/step_definitions/endpoint_steps.rb delete mode 100644 api/features/step_definitions/group_steps.rb delete mode 100644 api/features/step_definitions/institution_steps.rb delete mode 100644 api/features/step_definitions/network_steps.rb delete mode 100644 api/features/step_definitions/user_steps.rb delete mode 100644 api/features/support/env.rb delete mode 100644 api/spec/repositories/client_spec.rb delete mode 100644 api/spec/repositories/collection_spec.rb delete mode 100644 api/spec/repositories/group_spec.rb delete mode 100644 api/spec/repositories/institution_spec.rb delete mode 100644 api/spec/repositories/location_spec.rb delete mode 100644 api/spec/repositories/network_spec.rb delete mode 100644 api/spec/repositories/user_spec.rb delete mode 100644 api/spec/spec_helper.rb delete mode 100644 api/spec/yabeda/create_count_spec.rb delete mode 100644 api/spec/yabeda/delete_count_spec.rb delete mode 100644 api/spec/yabeda/index_count_spec.rb delete mode 100644 api/spec/yabeda/read_count_spec.rb delete mode 100644 api/spec/yabeda/update_count_spec.rb delete mode 100644 cli/.envrc delete mode 100644 cli/.gitignore delete mode 100644 cli/.rspec delete mode 100644 cli/.ruby-version delete mode 100644 cli/.standard.yml delete mode 100644 cli/Dockerfile delete mode 100644 cli/Dockerfile.prod delete mode 100644 cli/Gemfile delete mode 100644 cli/Gemfile.lock delete mode 100644 cli/LICENSE delete mode 100644 cli/README.md delete mode 100644 cli/app/create.rb delete mode 100644 cli/app/delete.rb delete mode 100644 cli/app/ipv4.rb delete mode 100644 cli/app/list.rb delete mode 100644 cli/app/query.rb delete mode 100644 cli/app/read.rb delete mode 100644 cli/app/update.rb delete mode 100755 cli/bin/cucumber delete mode 100755 cli/bin/lauth delete mode 100755 cli/bin/rspec delete mode 100755 cli/bin/standardrb delete mode 100644 cli/cli.rb delete mode 100644 cli/cucumber.yml delete mode 100644 cli/features/authorized.feature delete mode 100644 cli/features/crud/clients.feature delete mode 100644 cli/features/crud/collections.feature delete mode 100644 cli/features/crud/groups.feature delete mode 100644 cli/features/crud/institutions.feature delete mode 100644 cli/features/crud/networks.feature delete mode 100644 cli/features/crud/users.feature delete mode 100644 cli/features/ipv4.feature delete mode 100644 cli/features/query_networks.feature delete mode 100644 cli/features/step_definitions/client_steps.rb delete mode 100644 cli/features/step_definitions/colection_steps.rb delete mode 100644 cli/features/step_definitions/group_steps.rb delete mode 100644 cli/features/step_definitions/institution_steps.rb delete mode 100644 cli/features/step_definitions/lauth_steps.rb delete mode 100644 cli/features/step_definitions/network_steps.rb delete mode 100644 cli/features/step_definitions/user_steps.rb delete mode 100644 cli/features/support/env.rb delete mode 100644 cli/lauth.rdoc delete mode 100644 cli/spec/api_repositories/client_spec.rb delete mode 100644 cli/spec/api_repositories/collection_spec.rb delete mode 100644 cli/spec/api_repositories/group_spec.rb delete mode 100644 cli/spec/api_repositories/institution_spec.rb delete mode 100644 cli/spec/api_repositories/network_spec.rb delete mode 100644 cli/spec/api_repositories/user_spec.rb delete mode 100644 cli/spec/spec_helper.rb diff --git a/.github/workflows/build-cli-latest.yml b/.github/workflows/build-cli-latest.yml deleted file mode 100644 index 5e3657b7..00000000 --- a/.github/workflows/build-cli-latest.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: Build CLI latest from main (or manually from a selected branch) - -on: - workflow_dispatch: # This allows to kick-off the action manually from GitHub Actions - push: - branches: [ main ] # This watches pushes to the "main" branch - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build image and push to GitHub Container Registry - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: 'ghcr.io/mlibrary/lauth/lauth-cli:${{ github.sha }}, ghcr.io/mlibrary/lauth/lauth-cli:latest' - file: cli/Dockerfile.prod diff --git a/.github/workflows/build-api-latest.yml b/.github/workflows/build-lauth-latest.yml similarity index 57% rename from .github/workflows/build-api-latest.yml rename to .github/workflows/build-lauth-latest.yml index 8c62fdd8..6c533ed9 100644 --- a/.github/workflows/build-api-latest.yml +++ b/.github/workflows/build-lauth-latest.yml @@ -1,5 +1,6 @@ --- -name: Build API latest from main (or manually from a selected branch) +name: Build Lauth webapp +description: Builds the webapp (api and admin) from main or manually from a selected branch on: workflow_dispatch: # This allows to kick-off the action manually from GitHub Actions @@ -11,22 +12,23 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build image and push to GitHub Container Registry - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . push: true - tags: 'ghcr.io/mlibrary/lauth/lauth-api:${{ github.sha }}, ghcr.io/mlibrary/lauth/lauth-api:latest' - file: api/Dockerfile.prod + tags: 'ghcr.io/mlibrary/lauth/lauth:${{ github.sha }}, ghcr.io/mlibrary/lauth/lauth:latest' + file: lauth/Dockerfile + target: production diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c389078..00ccc88f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,8 +15,7 @@ jobs: fail-fast: false matrix: suite: -# - 'api' -# - 'cli' + - 'app' - 'test' ruby: - '3.2.2' @@ -33,20 +32,14 @@ jobs: echo "UID=$(id -u)" > .env echo "GID=$(id -g)" >> .env - - if: matrix.suite == 'api' + - if: matrix.suite == 'app' run: | - docker compose build --build-arg RUBY_VERSION=${{ matrix.ruby }} api - docker compose run api bundle exec rake db:migrate - docker compose run api bin/standardrb - docker compose run api bin/rspec - docker compose run api bin/cucumber - - if: matrix.suite == 'cli' - run: | - docker compose build --build-arg RUBY_VERSION=${{ matrix.ruby }} api cli - docker compose up -d api - docker compose exec api bundle exec rake db:migrate - docker compose run cli + docker compose build --build-arg RUBY_VERSION=${{ matrix.ruby }} app + # docker compose run app bundle exec rake db:migrate + # docker compose run app-dev bin/standardrb + docker compose run app-dev + # docker compose run api bin/cucumber - if: matrix.suite == 'test' run: | - docker compose build --build-arg RUBY_VERSION=${{ matrix.ruby }} api apache + docker compose build --build-arg RUBY_VERSION=${{ matrix.ruby }} app apache docker compose run test diff --git a/api/.envrc b/api/.envrc deleted file mode 100644 index 234188db..00000000 --- a/api/.envrc +++ /dev/null @@ -1 +0,0 @@ -PATH_add bin diff --git a/api/.gitignore b/api/.gitignore deleted file mode 100644 index 592d662e..00000000 --- a/api/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -*.gem -*.rbc -/.config -/coverage/ -/InstalledFiles -/pkg/ -/spec/reports/ -/spec/examples.txt -.rspec_status -/test/tmp/ -/test/version_tmp/ -/tmp/ -.bash_history -.cache/ - -# Used by dotenv library to load environment variables. -.env - -# Used by config library to load local settings. -/config/settings.local.yml - -# Ignore Byebug command history file. -.byebug_history - -## Documentation cache and generated files: -/.yardoc/ -/_yardoc/ -/doc/ -/rdoc/ - -## Environment normalization: -/.bundle/ -/vendor/bundle -/lib/bundler/man/ - diff --git a/api/.rspec b/api/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/api/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/api/.ruby-version b/api/.ruby-version deleted file mode 100644 index ef538c28..00000000 --- a/api/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -3.1.2 diff --git a/api/.standard.yml b/api/.standard.yml deleted file mode 100644 index 41caa771..00000000 --- a/api/.standard.yml +++ /dev/null @@ -1,3 +0,0 @@ -# For available configuration options, see: -# https://github.com/testdouble/standard - diff --git a/api/Dockerfile b/api/Dockerfile deleted file mode 100644 index 73ddf1c5..00000000 --- a/api/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -ARG RUBY_VERSION=3.2.2 -FROM ruby:${RUBY_VERSION} - -ARG BUNDLER_VERSION=2.4.21 -ARG UNAME=lauth -ARG UID=1000 -ARG GID=1000 - -LABEL maintainer="dla-staff@umich.edu" - -# Install Vim (optional) -RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ - vim-tiny - -RUN gem install bundler:${BUNDLER_VERSION} - -RUN groupadd -g ${GID} -o ${UNAME} -RUN useradd -m -d /lauth -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME} -RUN chown -R ${UID}:${GID} /usr/local/bundle -RUN mkdir -p /lauth/api /lauth/lib -RUN mkdir -p /gems && chown ${UID}:${GID} /gems - -ENV BUNDLE_PATH /gems - -WORKDIR /lauth/api -COPY --chown=${UID}:${GID} api/Gemfile* /lauth/api - -USER $UNAME - -RUN bundle install - -COPY api/ /lauth/api -COPY lib/ /lauth/lib - -EXPOSE 9292 -CMD ["bin/rackup", "-o", "0.0.0.0", "-p", "9292"] diff --git a/api/Dockerfile.prod b/api/Dockerfile.prod deleted file mode 100644 index 7f2b31c5..00000000 --- a/api/Dockerfile.prod +++ /dev/null @@ -1,37 +0,0 @@ -ARG RUBY_VERSION=3.1 -FROM ruby:${RUBY_VERSION} - -ARG BUNDLER_VERSION=2.3 -ARG UNAME=lauth -ARG UID=1001 -ARG GID=1001 - -LABEL maintainer="dla-staff@umich.edu" - -# Install Vim (optional) -RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ - vim-tiny - -RUN gem install bundler:${BUNDLER_VERSION} - -RUN groupadd -g ${GID} -o ${UNAME} -RUN useradd -m -d /lauth -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME} -RUN mkdir -p /lauth/api -RUN mkdir -p /lauth/lib -RUN mkdir -p /lauth/gems - -ENV BUNDLE_PATH /lauth/gems - -WORKDIR /lauth/api -COPY api/Gemfile* /lauth/api -RUN bundle install - -COPY api/ /lauth/api -COPY lib/ /lauth/lib - -RUN chown -R ${UID}:${GID} /lauth - -USER $UNAME - -EXPOSE 9292 -CMD ["bin/rackup", "-o", "0.0.0.0", "-p", "9292"] diff --git a/api/Gemfile b/api/Gemfile deleted file mode 100644 index d2a5f650..00000000 --- a/api/Gemfile +++ /dev/null @@ -1,24 +0,0 @@ -source "https://rubygems.org" - -gem "config", "~> 4.0.0" -gem "dotenv", "~> 2.7.6" -gem "hanami-api", git: "https://github.com/hanami/api", ref: "10c0d3b79232e933dd4e9e74bb2c6feb4a1f539e" -gem "ipaddress" -gem "mysql2", "~> 0.5.4" -gem "puma", "~> 5.6" -gem "rom", "~> 5.2.6" -gem "rom-http", git: "https://github.com/rom-rb/rom-http", ref: "f0507e52ba5f39a42ccfd24b0b6b88b86984c8de" -gem "rom-sql", "~> 3.5.0" -gem "yabeda-prometheus" -# gem 'yabeda-prometheus-mmap' -gem "yabeda-puma-plugin" - -# testing -gem "cucumber", "~> 8.0.0" -gem "database_cleaner-sequel" -gem "rack-test" -gem "rake" -gem "rom-factory" -gem "rspec", "~> 3.11" -gem "sequel" -gem "standard", "~> 1.12" diff --git a/api/Gemfile.lock b/api/Gemfile.lock deleted file mode 100644 index 6190fa00..00000000 --- a/api/Gemfile.lock +++ /dev/null @@ -1,254 +0,0 @@ -GIT - remote: https://github.com/hanami/api - revision: 10c0d3b79232e933dd4e9e74bb2c6feb4a1f539e - ref: 10c0d3b79232e933dd4e9e74bb2c6feb4a1f539e - specs: - hanami-api (0.2.0) - hanami-router (~> 2.0.alpha) - -GIT - remote: https://github.com/rom-rb/rom-http - revision: f0507e52ba5f39a42ccfd24b0b6b88b86984c8de - ref: f0507e52ba5f39a42ccfd24b0b6b88b86984c8de - specs: - rom-http (0.8.0) - addressable (~> 2.6) - concurrent-ruby (~> 1.1) - dry-configurable (~> 0.6) - dry-core (~> 0.4) - dry-equalizer (~> 0.2) - rom (~> 5.0, >= 5.0.1) - -GEM - remote: https://rubygems.org/ - specs: - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) - anyway_config (2.3.0) - ruby-next-core (>= 0.14.0) - ast (2.4.2) - builder (3.2.4) - concurrent-ruby (1.1.10) - config (4.0.0) - deep_merge (~> 1.2, >= 1.2.1) - dry-validation (~> 1.0, >= 1.0.0) - cucumber (8.0.0) - builder (~> 3.2, >= 3.2.4) - cucumber-ci-environment (~> 9.0, >= 9.0.4) - cucumber-core (~> 11.0, >= 11.0.0) - cucumber-cucumber-expressions (~> 15.1, >= 15.1.1) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-html-formatter (~> 19.1, >= 19.1.0) - cucumber-messages (~> 18.0, >= 18.0.0) - diff-lcs (~> 1.5, >= 1.5.0) - mime-types (~> 3.4, >= 3.4.1) - multi_test (~> 1.1, >= 1.1.0) - sys-uname (~> 1.2, >= 1.2.2) - cucumber-ci-environment (9.1.0) - cucumber-core (11.0.0) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-tag-expressions (~> 4.1, >= 4.1.0) - cucumber-cucumber-expressions (15.2.0) - cucumber-gherkin (23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-html-formatter (19.2.0) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-messages (18.0.0) - cucumber-tag-expressions (4.1.0) - database_cleaner-core (2.0.1) - database_cleaner-sequel (2.0.2) - database_cleaner-core (~> 2.0.0) - sequel - deep_merge (1.2.2) - diff-lcs (1.5.0) - dotenv (2.7.6) - dry-configurable (0.16.1) - dry-core (~> 0.6) - zeitwerk (~> 2.6) - dry-container (0.11.0) - concurrent-ruby (~> 1.0) - dry-core (0.8.1) - concurrent-ruby (~> 1.0) - dry-equalizer (0.3.0) - dry-inflector (0.3.0) - dry-initializer (3.1.1) - dry-logic (1.2.0) - concurrent-ruby (~> 1.0) - dry-core (~> 0.5, >= 0.5) - dry-schema (1.10.6) - concurrent-ruby (~> 1.0) - dry-configurable (~> 0.13, >= 0.13.0) - dry-core (~> 0.5, >= 0.5) - dry-initializer (~> 3.0) - dry-logic (~> 1.2) - dry-types (~> 1.5) - dry-struct (1.4.0) - dry-core (~> 0.5, >= 0.5) - dry-types (~> 1.5) - ice_nine (~> 0.11) - dry-types (1.5.1) - concurrent-ruby (~> 1.0) - dry-container (~> 0.3) - dry-core (~> 0.5, >= 0.5) - dry-inflector (~> 0.1, >= 0.1.2) - dry-logic (~> 1.0, >= 1.0.2) - dry-validation (1.8.1) - concurrent-ruby (~> 1.0) - dry-container (~> 0.7, >= 0.7.1) - dry-core (~> 0.5, >= 0.5) - dry-initializer (~> 3.0) - dry-schema (~> 1.8, >= 1.8.0) - faker (2.23.0) - i18n (>= 1.8.11, < 2) - ffi (1.15.5) - hanami-router (2.0.0.beta2) - mustermann (~> 1.0) - mustermann-contrib (~> 1.0) - rack (~> 2.0) - hansi (0.2.1) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - ice_nine (0.11.2) - ipaddress (0.8.3) - json (2.6.2) - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - multi_test (1.1.0) - mustermann (1.1.2) - ruby2_keywords (~> 0.0.1) - mustermann-contrib (1.1.2) - hansi (~> 0.2.0) - mustermann (= 1.1.2) - mysql2 (0.5.4) - nio4r (2.5.8) - parallel (1.22.1) - parser (3.1.2.1) - ast (~> 2.4.1) - prometheus-client (2.1.0) - public_suffix (5.0.0) - puma (5.6.5) - nio4r (~> 2.0) - rack (2.2.4) - rack-test (2.0.2) - rack (>= 1.3) - rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.6.0) - rexml (3.2.5) - rom (5.2.6) - rom-changeset (~> 5.2, >= 5.2.3) - rom-core (~> 5.2, >= 5.2.5) - rom-repository (~> 5.2, >= 5.2.2) - rom-changeset (5.2.3) - dry-core (~> 0.4) - rom-core (~> 5.2) - transproc (~> 1.0, >= 1.1.0) - rom-core (5.2.6) - concurrent-ruby (~> 1.1) - dry-container (~> 0.7) - dry-core (~> 0.4) - dry-equalizer (~> 0.2) - dry-inflector (~> 0.1) - dry-initializer (~> 3.0, >= 3.0.1) - dry-struct (~> 1.0) - dry-types (~> 1.0) - transproc (~> 1.0, >= 1.1.0) - rom-factory (0.10.2) - dry-configurable (~> 0.7) - dry-core (~> 0.4) - faker (>= 1.7, < 3.0) - rom-core (~> 5.0) - rom-repository (5.2.2) - dry-core (~> 0.4) - dry-initializer (~> 3.0, >= 3.0.1) - rom-core (~> 5.2, >= 5.2.2) - rom-sql (3.5.0) - dry-core (~> 0.5, >= 0.5) - dry-types (~> 1.0) - rom (~> 5.2, >= 5.2.1) - sequel (>= 4.49) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.1) - rubocop (1.35.1) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.1.2.1) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.20.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.21.0) - parser (>= 3.1.1.0) - rubocop-performance (1.14.3) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - ruby-next-core (0.15.2) - ruby-progressbar (1.11.0) - ruby2_keywords (0.0.5) - sequel (5.61.0) - standard (1.16.1) - rubocop (= 1.35.1) - rubocop-performance (= 1.14.3) - sys-uname (1.2.2) - ffi (~> 1.1) - transproc (1.1.1) - unicode-display_width (2.3.0) - yabeda (0.11.0) - anyway_config (>= 1.0, < 3) - concurrent-ruby - dry-initializer - yabeda-prometheus (0.8.0) - prometheus-client (>= 0.10, < 3.0) - rack - yabeda (~> 0.10) - yabeda-puma-plugin (0.6.0) - json - puma - yabeda (~> 0.5) - zeitwerk (2.6.1) - -PLATFORMS - aarch64-linux - arm64-darwin-20 - arm64-darwin-21 - arm64-darwin-22 - x86_64-linux - -DEPENDENCIES - config (~> 4.0.0) - cucumber (~> 8.0.0) - database_cleaner-sequel - dotenv (~> 2.7.6) - hanami-api! - ipaddress - mysql2 (~> 0.5.4) - puma (~> 5.6) - rack-test - rake - rom (~> 5.2.6) - rom-factory - rom-http! - rom-sql (~> 3.5.0) - rspec (~> 3.11) - sequel - standard (~> 1.12) - yabeda-prometheus - yabeda-puma-plugin - -BUNDLED WITH - 2.4.21 diff --git a/api/LICENSE b/api/LICENSE deleted file mode 100644 index b7af7b25..00000000 --- a/api/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2022, University of Michigan Library -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/api/README.md b/api/README.md deleted file mode 100644 index fe36d291..00000000 --- a/api/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# lauth-api - Library Authorization API - -A REST API to provide the functionality of the legacy auth database over HTTPS, -rather than a direct connection and SQL queries from the clients. - -Tools used for implementation - - - [Hanami::API](https://github.com/hanami/api) - Mini-framework handling HTTP, - routing, and seriazliation. - - [ROM](https://rom-rb.org/) - Ruby Object Mapper; used to build repositories, - entities, and SQL mapping. - -## NOTE: Stub status! - -As it stands, this is a minimal stub, intended to plumb together the pieces. -It's not really an API yet and everything is inlined. The individual endpoints -(for different resources / actions) will likely be separated out and hooked -into the Lauth::API (e.g., `get "/users", to: UsersEndpoint.new`). The data -mapping and interactors will likely move out to `lib`. - -The stub API responds to two URL routes: - - - **GET /** - A static message with the version - - **GET /users/:id** - A JSON-rendered `aa_user` row for the supplied userid - -## Directory Layout - -The directory structure is set up to make space for code unrelated to serving -the API to be extracted and shared. The lib directory at the top level is that -space. This mostly follows the Hanami / "Clean Architecture" convention. - -The Compose file uses the top level as the build context for the container, -copying this directory in as `/lauth/api` and the sibling `lib` directory as -`/lauth/lib`. - -## Running the API - -The API can be run under Docker Compose. There is a gem cache, so the bundle -will not need to be built on each app change. For now, there is no code -reloading. - -You can build the image from the top level directory with: - -``` -docker compose build api -``` - -You can run it (optionally with the `-d` flag to put it in the background with: - -``` -docker compose up api -``` - -The api service will forward port 9292, meaning you should be able to load -http://localhost:9292 in a browser. - -### Running locally (not in a container) - -You could also run the API locally, with a Ruby 3.1 environment and by setting -the database URL, as in the next section. The API is a Rack app, and there is -a rackup file, `config.ru`. There is also a binstub, so you can start it up -with: - -``` -bin/rackup -``` - -## Connecting to the database - -By default, the API connects to the database in the `mariadb` service, with -the default credentials. If you need to change this, you can set a connection -string in the `DATABASE_URL` environment variable. diff --git a/api/Rakefile b/api/Rakefile deleted file mode 100644 index 77847c0d..00000000 --- a/api/Rakefile +++ /dev/null @@ -1,9 +0,0 @@ -require_relative "api" -require "rom/sql/rake_task" - -namespace :db do - task :setup do - configuration = ROM::Configuration.new(:sql, Settings.db.to_h) - ROM::SQL::RakeSupport.env = configuration - end -end diff --git a/api/api.rb b/api/api.rb deleted file mode 100644 index da660582..00000000 --- a/api/api.rb +++ /dev/null @@ -1,645 +0,0 @@ -require "dotenv" -require "config" -require "hanami/api" -require "base64" - -$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__)) -require "lauth" - -require "yabeda" -require "yabeda/prometheus" - -module Lauth - module API - Dotenv.load - - Config.setup do |config| - config.const_name = "Settings" - config.use_env = true - config.env_prefix = "LAUTH_API" - config.env_separator = "_" - config.env_converter = :downcase - config.env_parse_values = true - end - - Config.load_and_set_settings(Config.setting_files(__dir__ + "/config", nil)) - - Yabeda.configure do - group :lauth do - counter :index_count, comment: "Total number of index request", tags: %i[resource] - counter :create_count, comment: "Total number of create request", tags: %i[resource] - counter :read_count, comment: "Total number of read request", tags: %i[resource] - counter :update_count, comment: "Total number of update request", tags: %i[resource] - counter :delete_count, comment: "Total number of delete request", tags: %i[resource] - end - end - - class APP < Hanami::API - Yabeda.configure! - # Yabeda.debug! - - module Authentication - private - - def authorized! - # puts env - errors = '{"errors":[{"error":{"code":401,"msg":"Unauthorized"}}]}' - halt(401, errors) unless env["HTTP_X_AUTH"] # User Anonymous - plain = Base64.decode64(env["HTTP_X_AUTH"]) - username, password = plain.split(":") - user_repo = Lauth::API::Repositories::User.new(BDD.rom) - user = user_repo.read(username) - halt(401, errors) unless user # User Unknown - halt(401, errors) unless user.password == password # User Wrong Password - end - end - - helpers(Authentication) - - get "/" do - Settings.db.to_h.to_s - end - - # CLIENTS - - # index clients - get "/clients" do - Yabeda.lauth.index_count.increment({resource: "clients"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Client.new(BDD.rom) - document = {} - clients = [] - repo.index.each do |client| - clients << client.resource_object - end - document[:data] = clients - document.to_json - end - - # create client - post "/clients" do - Yabeda.lauth.create_count.increment({resource: "clients"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Client.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - client = repo.create(document) - - if client - document = {} - document[:data] = client.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":403,"msg":"Forbidden"}}]}' - halt(403, errors) - end - end - - # read client - get "/clients/:id" do |id| - Yabeda.lauth.read_count.increment({resource: "clients"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Client.new(BDD.rom) - client = repo.read(params[:id]) - - if client - document = {} - document[:data] = client.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # update client - put "/clients/:id" do |id| - Yabeda.lauth.update_count.increment({resource: "clients"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Client.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - client = repo.update(document) - - if client - document = {} - document[:data] = client.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # delete client - delete "/clients/:id" do |id| - Yabeda.lauth.delete_count.increment({resource: "clients"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Client.new(BDD.rom) - client = repo.read(params[:id]) - - if client - repo.delete(params[:id]) - document = {} - document[:data] = client.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # COLLECTIONS - - # index collections - get "/collections" do - Yabeda.lauth.index_count.increment({resource: "collections"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Collection.new(BDD.rom) - document = {} - collections = [] - repo.index.each do |collection| - collections << collection.resource_object - end - document[:data] = collections - document.to_json - end - - # create collection - post "/collections" do - Yabeda.lauth.create_count.increment({resource: "collections"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Collection.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - collection = repo.create(document) - - if collection - document = {} - document[:data] = collection.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":403,"msg":"Forbidden"}}]}' - halt(403, errors) - end - end - - # read collection - get "/collections/:id" do |id| - Yabeda.lauth.read_count.increment({resource: "collections"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Collection.new(BDD.rom) - collection = repo.read(params[:id]) - - if collection - document = {} - document[:data] = collection.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # update collection - put "/collections/:id" do |id| - Yabeda.lauth.update_count.increment({resource: "collections"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Collection.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - collection = repo.update(document) - - if collection - document = {} - document[:data] = collection.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # delete collection - delete "/collections/:id" do |id| - Yabeda.lauth.delete_count.increment({resource: "collections"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Collection.new(BDD.rom) - collection = repo.read(params[:id]) - - if collection - repo.delete(params[:id]) - document = {} - document[:data] = collection.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # GROUPS - - # index groups - get "/groups" do - Yabeda.lauth.index_count.increment({resource: "groups"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Group.new(BDD.rom) - document = {} - groups = [] - repo.index.each do |group| - groups << group.resource_object - end - document[:data] = groups - document.to_json - end - - # create group - post "/groups" do - Yabeda.lauth.create_count.increment({resource: "groups"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Group.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - group = repo.create(document) - - if group - document = {} - document[:data] = group.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":403,"msg":"Forbidden"}}]}' - halt(403, errors) - end - end - - # read group - get "/groups/:id" do |id| - Yabeda.lauth.read_count.increment({resource: "groups"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Group.new(BDD.rom) - group = repo.read(params[:id]) - - if group - document = {} - document[:data] = group.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # update group - put "/groups/:id" do |id| - Yabeda.lauth.update_count.increment({resource: "groups"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Group.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - group = repo.update(document) - - if group - document = {} - document[:data] = group.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # delete group - delete "/groups/:id" do |id| - Yabeda.lauth.delete_count.increment({resource: "groups"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Group.new(BDD.rom) - group = repo.read(params[:id]) - - if group - repo.delete(params[:id]) - document = {} - document[:data] = group.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # INSTITUTIONS - - # index institutions - get "/institutions" do - Yabeda.lauth.index_count.increment({resource: "institutions"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Institution.new(BDD.rom) - document = {} - institutions = [] - repo.index.each do |institution| - institutions << institution.resource_object - end - document[:data] = institutions - document.to_json - end - - # create institution - post "/institutions" do - Yabeda.lauth.create_count.increment({resource: "institutions"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Institution.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - institution = repo.create(document) - - if institution - document = {} - document[:data] = institution.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":403,"msg":"Forbidden"}}]}' - halt(403, errors) - end - end - - # read institution - get "/institutions/:id" do |id| - Yabeda.lauth.read_count.increment({resource: "institutions"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Institution.new(BDD.rom) - institution = repo.read(params[:id]) - - if institution - document = {} - document[:data] = institution.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # update institution - put "/institutions/:id" do |id| - Yabeda.lauth.update_count.increment({resource: "institutions"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Institution.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - institution = repo.update(document) - - if institution - document = {} - document[:data] = institution.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # delete institution - delete "/institutions/:id" do |id| - Yabeda.lauth.delete_count.increment({resource: "institutions"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Institution.new(BDD.rom) - institution = repo.read(params[:id]) - - if institution - repo.delete(params[:id]) - document = {} - document[:data] = institution.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # NETWORKS - - # index networks - get "/networks" do - Yabeda.lauth.index_count.increment({resource: "networks"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Network.new(BDD.rom) - - query = if params[:ip] - ip = IPAddress.parse params[:ip] - repo.include?(ip) - else - repo.index - end - - document = {} - networks = [] - query.each do |network| - networks << network.resource_object - end - document[:data] = networks - document.to_json - end - - # create network - post "/networks" do - Yabeda.lauth.create_count.increment({resource: "networks"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Network.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - network = repo.create(document) - - if network - document = {} - document[:data] = network.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":403,"msg":"Forbidden"}}]}' - halt(403, errors) - end - end - - # read network - get "/networks/:id" do |id| - Yabeda.lauth.read_count.increment({resource: "networks"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Network.new(BDD.rom) - network = repo.read(params[:id]) - - if network - document = {} - document[:data] = network.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # update network - put "/networks/:id" do |id| - Yabeda.lauth.update_count.increment({resource: "networks"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Network.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - network = repo.update(document) - - if network - document = {} - document[:data] = network.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # delete network - delete "/networks/:id" do |id| - Yabeda.lauth.delete_count.increment({resource: "networks"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::Network.new(BDD.rom) - network = repo.read(params[:id]) - - if network - repo.delete(params[:id]) - document = {} - document[:data] = network.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # USERS - - # index users - get "/users" do - Yabeda.lauth.index_count.increment({resource: "users"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::User.new(BDD.rom) - document = {} - users = [] - repo.index.each do |user| - users << user.resource_object - end - document[:data] = users - document.to_json - end - - # create user - post "/users" do - Yabeda.lauth.create_count.increment({resource: "users"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::User.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - user = repo.create(document) - - if user - document = {} - document[:data] = user.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":403,"msg":"Forbidden"}}]}' - halt(403, errors) - end - end - - # read user - get "/users/:id" do |id| - Yabeda.lauth.read_count.increment({resource: "users"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::User.new(BDD.rom) - user = repo.read(params[:id]) - - if user - document = {} - document[:data] = user.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # update user - put "/users/:id" do |id| - Yabeda.lauth.update_count.increment({resource: "users"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::User.new(BDD.rom) - document = JSON.parse(env["rack.input"].gets) - user = repo.update(document) - - if user - document = {} - document[:data] = user.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - - # delete user - delete "/users/:id" do |id| - Yabeda.lauth.delete_count.increment({resource: "users"}, by: 1) - authorized! - - repo = Lauth::API::Repositories::User.new(BDD.rom) - user = repo.delete(params[:id]) - - if user - document = {} - document[:data] = user.resource_object - document.to_json - else - errors = '{"errors":[{"error":{"code":404,"msg":"Not Found"}}]}' - halt(404, errors) - end - end - end - - # Totally cheesy db stub; move to real config/boot - class DB - def self.rom - @@rom ||= ::ROM.container( - :sql, - ENV.fetch("DATABASE_URL", "mysql2://mariadb/lauth?username=lauth&password=lauth") - ) do |config| - config.relation(:aa_user) do - schema(infer: true) - end - end - end - end - - class BDD - def self.rom - @@rom ||= ::ROM.container(:sql, Settings.db.to_h) do |config| - config.auto_registration("../lib/lauth/api/rom", namespace: "Lauth::API::ROM") - end - end - end - end -end diff --git a/api/bin/cucumber b/api/bin/cucumber deleted file mode 100755 index 9cb3ddb1..00000000 --- a/api/bin/cucumber +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'cucumber' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -bundle_binstub = File.expand_path("../bundle", __FILE__) - -if File.file?(bundle_binstub) - if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300)) - load(bundle_binstub) - else - abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. -Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") - end -end - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("cucumber", "cucumber") diff --git a/api/bin/rackup b/api/bin/rackup deleted file mode 100755 index e010b449..00000000 --- a/api/bin/rackup +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'rackup' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -bundle_binstub = File.expand_path("../bundle", __FILE__) - -if File.file?(bundle_binstub) - if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300)) - load(bundle_binstub) - else - abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. -Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") - end -end - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("rack", "rackup") diff --git a/api/bin/rspec b/api/bin/rspec deleted file mode 100755 index 4305353d..00000000 --- a/api/bin/rspec +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'rspec' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -bundle_binstub = File.expand_path("../bundle", __FILE__) - -if File.file?(bundle_binstub) - if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300)) - load(bundle_binstub) - else - abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. -Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") - end -end - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("rspec-core", "rspec") diff --git a/api/bin/standardrb b/api/bin/standardrb deleted file mode 100755 index fe07d50b..00000000 --- a/api/bin/standardrb +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'standardrb' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -bundle_binstub = File.expand_path("../bundle", __FILE__) - -if File.file?(bundle_binstub) - if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300)) - load(bundle_binstub) - else - abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. -Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") - end -end - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("standard", "standardrb") diff --git a/api/config.ru b/api/config.ru deleted file mode 100644 index 942eddce..00000000 --- a/api/config.ru +++ /dev/null @@ -1,6 +0,0 @@ -require_relative "api" -require "yabeda/prometheus" - -use Yabeda::Prometheus::Exporter - -run Lauth::API::APP.new diff --git a/api/config/puma.rb b/api/config/puma.rb deleted file mode 100644 index dba5abbe..00000000 --- a/api/config/puma.rb +++ /dev/null @@ -1,3 +0,0 @@ -activate_control_app -plugin :yabeda -plugin :yabeda_prometheus # http://0.0.0.0:9394/metrics (default) diff --git a/api/config/settings.yml b/api/config/settings.yml deleted file mode 100644 index ce4965d3..00000000 --- a/api/config/settings.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -# DATABASE GENERAL CONNECTION OPTIONS -# -# Options below are available to all database drivers and can be used to -# configure the connection between ROM and the database. -# -# Option Value Type Description -# :adapter Symbol Sets the database driver which should be used when making a connection. -# This option is only to be used in situations where a connection string is -# NOT provided to the ROM Configuration instance. -# Available Options: -# :postgres -# :sqlite -# :oracle -# :mysql -# :mysql2 -# :host String Internet location of the database server. -# This option is required when the adapter option is being used. -# :port Integer Port number used during connection. -# :database String Name of the database to open after successful connection. -# :user String Name of the user account to use when logging in. -# :password String Password that matches the user account. -# :max_connections Integer The maximum number of connections the connection pool will open (default 4). -# -# MYSQL ADDITIONAL OPTIONS -# -# Option Value Type Default Value Description -# :encoding String 'UTF8' Specify the encoding/character set to use for the connection. -# Available encodings can be found in the MySQL Charset Table. -# The most common option being 'UTF8' -# :write_timeout Integer Set the timeout in seconds when writing to the database. -# :read_timeout Integer Set the timeout in seconds when reading query results. -# :connect_timeout Integer Set the timeout in seconds before a connection attempt is abandoned. -# :secure_auth Boolean true When enabled the server will refuse connection if the account password is stored in old pre-MySQL 4.1 format. -# :sql_mode Array, Sets the sql_mode(s) for a given connection. eg: [:no_zero_date, :pipes_as_concat] -# String, Symbol Available sql_modes can be found in MySQL Server SQL Modes documentation. -# :flags String, Array Flags added to an array are added to the Default flags, -# while flags with a - (minus) prefix are removed from the default flags. -# For more information see Flag Option Parsing. -# Available Options: -# 'REMEMBER_OPTIONS' -# 'LONG_PASSWORD' -# 'LONG_FLAG' -# 'TRANSACTIONS' -# 'PROTOCOL_41' -# 'SECURE_CONNECTION' -# 'MULTI_STATEMENTS' -# :socket String Used to specify a Unix socket file to connect to instead of a TCP host & port. -# :sslmode Symbol :disabled Determines the priority or whether or not a SSL TCP/IP connection is to be made. -# Available Options: -# :disabled - Establish an unencrypted connection -# :preferred - First try a non-SSL connection; if that fails, try an SSL connection -# :required - Establish a secure connection if the server supports secure connections -# :verify_ca - Only establish an SSL connection and verify the servers TLS certificate against the configured Certificate Authority (CA) certificates. -# :verify_identity - Like :verify_ca, but additionally verify the server certificate matches the host to which the connection is attempted. -# :sslkey String Path to the client key. eg: 'path/to/client-key.pem' -# :sslcert String Path to the client certificate. eg: 'path/to/client-cert.pem' -# :sslca String Path to the CA certificate. eg: '/path/to/ca-cert.pem' -# :sslcapath String Path to the CA certificates. eg. 'path/to/cacerts' -# :sslcipher String Supported ciphers can be found in the MySQL Encrypted Connection Protocols document. eg: 'DHE-RSA-AES256-SHA' -# :sslverify Boolean false When set to true, the server is required to present a valid certificate. -db: - adapter: :mysql2 - host: 'localhost' - port: 3306 - database: 'test' - user: 'root' - password: '' - encoding: 'utf8mb4' diff --git a/api/cucumber.yml b/api/cucumber.yml deleted file mode 100644 index 16f9a813..00000000 --- a/api/cucumber.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -default: --publish-quiet diff --git a/api/db/migrate/20220810151545_create_clients.rb b/api/db/migrate/20220810151545_create_clients.rb deleted file mode 100644 index 58365198..00000000 --- a/api/db/migrate/20220810151545_create_clients.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -ROM::SQL.migration do - change do - create_table :clients do - primary_key :id - column :name, String, null: false - end - end -end diff --git a/api/features/authenticate.feature b/api/features/authenticate.feature deleted file mode 100644 index 3c8c6f9c..00000000 --- a/api/features/authenticate.feature +++ /dev/null @@ -1,33 +0,0 @@ -Feature: Authenticate - - Scenario: User Anonymous - Given no user credentials - When I visit "users/root" - Then I should see - """ - {"errors":[{"error":{"code":401,"msg":"Unauthorized"}}]} - """ - - Scenario: User Unknown - Given user credentials "user:password" - When I visit "users/root" - Then I should see - """ - {"errors":[{"error":{"code":401,"msg":"Unauthorized"}}]} - """ - - Scenario: User Wrong Password - Given user credentials "root:password" - When I visit "users/root" - Then I should see - """ - {"errors":[{"error":{"code":401,"msg":"Unauthorized"}}]} - """ - - Scenario: User Correct Password - Given user credentials "root:!none" - When I visit "users/root" - Then I should see - """ - {"data":{"type":"users","id":"root","attributes":{"name":"User"}}} - """ diff --git a/api/features/crud/clients.feature b/api/features/crud/clients.feature deleted file mode 100644 index 2c5383ef..00000000 --- a/api/features/crud/clients.feature +++ /dev/null @@ -1,76 +0,0 @@ -Feature: CRUD Clients - - Background: - Given user "Name" with credentials "client:password" - Given the following clients exist: - | id | name | - | 1 | Name1 | - | 2 | Name2 | - | 3 | Name3 | - - Scenario: Clients - When I visit "clients" - Then I should see - """ - {"data":[ - {"type":"clients","id":1,"attributes":{"name":"Name1"}}, - {"type":"clients","id":2,"attributes":{"name":"Name2"}}, - {"type":"clients","id":3,"attributes":{"name":"Name3"}} - ]} - """ - - Scenario: Create Client - Not Found - When I post '{"data":{"type":"clients","id":4,"attributes":{"name":"4emaN"}}}' to "clients" - Then I should see - """ - {"data":{"type":"clients","id":4,"attributes":{"name":"4emaN"}}} - """ - - Scenario: Create Client - Found - When I post '{"data":{"type":"clients","id":3,"attributes":{"name":"3emaN"}}}' to "clients" - Then I should see - """ - {"errors":[{"error":{"code":403, "msg":"Forbidden"}}]} - """ - - Scenario: Read Client - Not Found - When I visit "clients/4" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Client - Found - When I visit "clients/3" - Then I should see - """ - {"data":{"type":"clients","id":3,"attributes":{"name":"Name3"}}} - """ - - Scenario: Update Client - Not Found - When I put '{"data":{"type":"clients","id":4,"attributes":{"name":"4emaN"}}}' to "clients/4" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Client - Found - When I put '{"data":{"type":"clients","id":3,"attributes":{"name":"3emaN"}}}' to "clients/3" - Then I should see - """ - {"data":{"type":"clients","id":3,"attributes":{"name":"3emaN"}}} - """ - - Scenario: Delete Client - Not Found - When I delete "clients/4" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Client - Found - When I delete "clients/3" - Then I should see - """ - {"data":{"type":"clients","id":3,"attributes":{"name":"Name3"}}} - """ diff --git a/api/features/crud/collections.feature b/api/features/crud/collections.feature deleted file mode 100644 index be7c0450..00000000 --- a/api/features/crud/collections.feature +++ /dev/null @@ -1,111 +0,0 @@ -Feature: CRUD Collections - - Background: - Given user "Name" with credentials "user:password" - Given the following collections exist: - | id | name | deleted | - | Identifier1 | Collection One | f | - | Identifier2 | Collection Two | f | - | Identifier3 | Collection Three | f | - | Identifier4 | Collection Four | t | - | Identifier5 | Collection Five | f | - | Identifier6 | Collection Six | t | - | Identifier7 | Collection Seven | f | - | Identifier8 | Collection Eight | t | - - Scenario: Collections - When I visit "collections" - Then I should see - """ - {"data":[ - {"type":"collections","id":"Identifier1","attributes":{"name":"Collection One"}}, - {"type":"collections","id":"Identifier2","attributes":{"name":"Collection Two"}}, - {"type":"collections","id":"Identifier3","attributes":{"name":"Collection Three"}}, - {"type":"collections","id":"Identifier5","attributes":{"name":"Collection Five"}}, - {"type":"collections","id":"Identifier7","attributes":{"name":"Collection Seven"}} - ]} - """ - - Scenario: Create Collection - Not Found (Unknown) - When I post '{"data":{"type":"collections","id":"Identifier9","attributes":{"name":"Nine Collection"}}}' to "collections" - Then I should see - """ - {"data":{"type":"collections","id":"Identifier9","attributes":{"name":"Nine Collection"}}} - """ - - Scenario: Create Collection - Not Found (Deleted) - When I post '{"data":{"type":"collections","id":"Identifier8","attributes":{"name":"Eight Collection"}}}' to "collections" - Then I should see - """ - {"data":{"type":"collections","id":"Identifier8","attributes":{"name":"Eight Collection"}}} - """ - - Scenario: Create Collection - Found - When I post '{"data":{"type":"collections","id":"Identifier3","attributes":{"name":"Three Collection"}}}' to "collections" - Then I should see - """ - {"errors":[{"error":{"code":403,"msg":"Forbidden"}}]} - """ - - Scenario: Read Collection - Not Found (Unknown) - When I visit "collections/Identifier9" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Collection - Not Found (Deleted) - When I visit "collections/Identifier8" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Collection - Found - When I visit "collections/Identifier3" - Then I should see - """ - {"data":{"type":"collections","id":"Identifier3","attributes":{"name":"Collection Three"}}} - """ - - Scenario: Update Collection - Not Found (Unknown) - When I put '{"data":{"type":"collections","id":"Identifier9","attributes":{"name":"Nine Collection"}}}' to "collections/Identifier9" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Collection - Not Found (Deleted) - When I put '{"data":{"type":"collections","id":"Identifier8","attributes":{"name":"Eight Collection"}}}' to "collections/Identifier8" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Collection - Found - When I put '{"data":{"type":"collections","id":"Identifier3","attributes":{"name":"Three Collection"}}}' to "collections/Identifier3" - Then I should see - """ - {"data":{"type":"collections","id":"Identifier3","attributes":{"name":"Three Collection"}}} - """ - - Scenario: Delete Collection - Not Found (Unknown) - When I delete "collections/Identifier9" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Collection - Not Found (Deleted) - When I delete "collections/Identifier8" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Collection - Found - When I delete "collections/Identifier3" - Then I should see - """ - {"data":{"type":"collections","id":"Identifier3","attributes":{"name":"Collection Three"}}} - """ diff --git a/api/features/crud/groups.feature b/api/features/crud/groups.feature deleted file mode 100644 index a41757ca..00000000 --- a/api/features/crud/groups.feature +++ /dev/null @@ -1,112 +0,0 @@ -Feature: CRUD Groups - - Background: - Given user "Name" with credentials "user:password" - Given the following groups exist: - | id | name | deleted | - | 1 | Group One | f | - | 2 | Group Two | f | - | 3 | Group Three | f | - | 4 | Group Four | t | - | 5 | Group Five | f | - | 6 | Group Six | t | - | 7 | Group Seven | f | - | 8 | Group Eight | t | - - Scenario: Groups - When I visit "groups" - Then I should see - """ - {"data":[ - {"type":"groups","id":0,"attributes":{"name":"root"}}, - {"type":"groups","id":1,"attributes":{"name":"Group One"}}, - {"type":"groups","id":2,"attributes":{"name":"Group Two"}}, - {"type":"groups","id":3,"attributes":{"name":"Group Three"}}, - {"type":"groups","id":5,"attributes":{"name":"Group Five"}}, - {"type":"groups","id":7,"attributes":{"name":"Group Seven"}} - ]} - """ - - Scenario: Create Group - Not Found (Unknown) - When I post '{"data":{"type":"groups","id":9,"attributes":{"name":"Nine"}}}' to "groups" - Then I should see - """ - {"data":{"type":"groups","id":9,"attributes":{"name":"Nine"}}} - """ - - Scenario: Create Group - Not Found (Deleted) - When I post '{"data":{"type":"groups","id":8,"attributes":{"name":"Eight"}}}' to "groups" - Then I should see - """ - {"data":{"type":"groups","id":8,"attributes":{"name":"Eight"}}} - """ - - Scenario: Create Group - Found - When I post '{"data":{"type":"groups","id":3,"attributes":{"name":"Three"}}}' to "groups" - Then I should see - """ - {"errors":[{"error":{"code":403, "msg":"Forbidden"}}]} - """ - - Scenario: Read Group - Not Found (Unknown) - When I visit "groups/9" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Group - Not Found (Deleted) - When I visit "groups/8" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Group - Found - When I visit "groups/3" - Then I should see - """ - {"data":{"type":"groups","id":3,"attributes":{"name":"Group Three"}}} - """ - - Scenario: Update Group - Not Found (Unknown) - When I put '{"data":{"type":"groups","id":9,"attributes":{"name":"Nine"}}}' to "groups/9" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Group - Not Found (Deleted) - When I put '{"data":{"type":"groups","id":8,"attributes":{"name":"Eight"}}}' to "groups/8" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Group - Found - When I put '{"data":{"type":"groups","id":3,"attributes":{"name":"Three"}}}' to "groups/3" - Then I should see - """ - {"data":{"type":"groups","id":3,"attributes":{"name":"Three"}}} - """ - - Scenario: Delete Group - Not Found (Unknown) - When I delete "groups/9" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Group - Not Found (Deleted) - When I delete "groups/8" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Group - Found - When I delete "groups/3" - Then I should see - """ - {"data":{"type":"groups","id":3,"attributes":{"name":"Group Three"}}} - """ diff --git a/api/features/crud/institutions.feature b/api/features/crud/institutions.feature deleted file mode 100644 index 556b295a..00000000 --- a/api/features/crud/institutions.feature +++ /dev/null @@ -1,111 +0,0 @@ -Feature: CRUD Institutions - - Background: - Given user "Name" with credentials "user:password" - Given the following institutions exist: - | id | name | deleted | - | 1 | University of Michigan | f | - | 2 | Michigan State University | f | - | 3 | Eastern Michigan University | f | - | 4 | Western Michigan University | t | - | 5 | Wayne State University | f | - | 6 | Central Michigan University | t | - | 7 | Michigan Technology University | f | - | 8 | Oakland University | t | - - Scenario: Institutions - When I visit "institutions" - Then I should see - """ - {"data":[ - {"type":"institutions","id":1,"attributes":{"name":"University of Michigan"}}, - {"type":"institutions","id":2,"attributes":{"name":"Michigan State University"}}, - {"type":"institutions","id":3,"attributes":{"name":"Eastern Michigan University"}}, - {"type":"institutions","id":5,"attributes":{"name":"Wayne State University"}}, - {"type":"institutions","id":7,"attributes":{"name":"Michigan Technology University"}} - ]} - """ - - Scenario: Create Institution - Not Found (Unknown) - When I post '{"data":{"type":"institutions","id":9,"attributes":{"name":"9emaN"}}}' to "institutions" - Then I should see - """ - {"data":{"type":"institutions","id":9,"attributes":{"name":"9emaN"}}} - """ - - Scenario: Create Institution - Not Found (Deleted) - When I post '{"data":{"type":"institutions","id":8,"attributes":{"name":"8emaN"}}}' to "institutions" - Then I should see - """ - {"data":{"type":"institutions","id":8,"attributes":{"name":"8emaN"}}} - """ - - Scenario: Create Institution - Found - When I post '{"data":{"type":"institutions","id":3,"attributes":{"name":"3emaN"}}}' to "institutions" - Then I should see - """ - {"errors":[{"error":{"code":403, "msg":"Forbidden"}}]} - """ - - Scenario: Read Institution - Not Found (Unknown) - When I visit "institutions/9" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Institution - Not Found (Deleted) - When I visit "institutions/8" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Institution - Found - When I visit "institutions/3" - Then I should see - """ - {"data":{"type":"institutions","id":3,"attributes":{"name":"Eastern Michigan University"}}} - """ - - Scenario: Update Institution - Not Found (Unknown) - When I put '{"data":{"type":"institutions","id":9,"attributes":{"name":"9emaN"}}}' to "institutions/9" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Institution - Not Found (Deleted) - When I put '{"data":{"type":"institutions","id":8,"attributes":{"name":"8emaN"}}}' to "institutions/8" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Institution - Found - When I put '{"data":{"type":"institutions","id":3,"attributes":{"name":"3emaN"}}}' to "institutions/3" - Then I should see - """ - {"data":{"type":"institutions","id":3,"attributes":{"name":"3emaN"}}} - """ - - Scenario: Delete Institution - Not Found (Unknown) - When I delete "institutions/9" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Institution - Not Found (Deleted) - When I delete "institutions/8" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Institution - Found - When I delete "institutions/3" - Then I should see - """ - {"data":{"type":"institutions","id":3,"attributes":{"name":"Eastern Michigan University"}}} - """ diff --git a/api/features/crud/networks.feature b/api/features/crud/networks.feature deleted file mode 100644 index 25e2ffc1..00000000 --- a/api/features/crud/networks.feature +++ /dev/null @@ -1,107 +0,0 @@ -Feature: CRUD Networks - - Background: - Given user "Name" with credentials "user:password" - Given the following networks exist: - | id | cidr | deleted | - | 1 | 1.2.3.3/8 | f | - | 2 | 2.2.3.3/8 | t | - | 3 | 128.0.3.3/16 | t | - | 4 | 128.1.3.3/16 | f | - | 5 | 192.0.0.3/24 | f | - | 6 | 192.0.1.3/24 | t | - - Scenario: Networks - When I visit "networks" - Then I should see - """ - {"data":[ - {"type":"networks","id":1,"attributes":{"cidr":"1.0.0.0/8","access":"allow"}}, - {"type":"networks","id":4,"attributes":{"cidr":"128.1.0.0/16","access":"allow"}}, - {"type":"networks","id":5,"attributes":{"cidr":"192.0.0.0/24","access":"allow"}} - ]} - """ - - Scenario: Create Network - Not Found (Unknown) - When I post '{"data":{"type":"networks","id":7,"attributes":{"cidr":"45.45.43.45/24"}}}' to "networks" - Then I should see - """ - {"data":{"type":"networks","id":7,"attributes":{"cidr":"45.45.43.0/24","access":"allow"}}} - """ - - Scenario: Create Network - Not Found (Deleted) - When I post '{"data":{"type":"networks","id":6,"attributes":{"cidr":"45.45.43.45/24"}}}' to "networks" - Then I should see - """ - {"data":{"type":"networks","id":6,"attributes":{"cidr":"45.45.43.0/24","access":"allow"}}} - """ - - Scenario: Create Network - Found - When I post '{"data":{"type":"networks","id":4,"attributes":{"cidr":"45.45.43.45/24"}}}' to "networks" - Then I should see - """ - {"errors":[{"error":{"code":403, "msg":"Forbidden"}}]} - """ - - Scenario: Read Network - Not Found (Unknown) - When I visit "networks/7" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Network - Not Found (Deleted) - When I visit "networks/6" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read Network - Found - When I visit "networks/4" - Then I should see - """ - {"data":{"type":"networks","id":4,"attributes":{"cidr":"128.1.0.0/16","access":"allow"}}} - """ - - Scenario: Update Network - Not Found (Unknown) - When I put '{"data":{"type":"networks","id":7,"attributes":{"cidr":"45.45.43.45/24"}}}' to "networks/7" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Network - Not Found (Deleted) - When I put '{"data":{"type":"networks","id":6,"attributes":{"cidr":"45.45.43.45/24"}}}' to "networks/6" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update Network - Found - When I put '{"data":{"type":"networks","id":4,"attributes":{"cidr":"45.45.43.45/24"}}}' to "networks/4" - Then I should see - """ - {"data":{"type":"networks","id":4,"attributes":{"cidr":"45.45.43.0/24","access":"allow"}}} - """ - - Scenario: Delete Network - Not Found (Unknown) - When I delete "networks/7" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Network - Not Found (Deleted) - When I delete "networks/6" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete Network - Found - When I delete "networks/4" - Then I should see - """ - {"data":{"type":"networks","id":4,"attributes":{"cidr":"128.1.0.0/16","access":"allow"}}} - """ diff --git a/api/features/crud/users.feature b/api/features/crud/users.feature deleted file mode 100644 index 1234654d..00000000 --- a/api/features/crud/users.feature +++ /dev/null @@ -1,113 +0,0 @@ -Feature: CRUD Users - - Background: - Given user "Name" with credentials "user:password" - Given the following users exist: - | id | name | deleted | - | user1 | Name1 | f | - | user2 | Name2 | f | - | user3 | Name3 | f | - | user4 | Name4 | t | - | user5 | Name5 | f | - | user6 | Name6 | t | - | user7 | Name7 | f | - | user8 | Name8 | t | - - Scenario: Index Users - When I visit "users" - Then I should see - """ - {"data":[ - {"type":"users","id":"root","attributes":{"name":"User"}}, - {"type":"users","id":"user","attributes":{"name":"Name"}}, - {"type":"users","id":"user1","attributes":{"name":"Name1"}}, - {"type":"users","id":"user2","attributes":{"name":"Name2"}}, - {"type":"users","id":"user3","attributes":{"name":"Name3"}}, - {"type":"users","id":"user5","attributes":{"name":"Name5"}}, - {"type":"users","id":"user7","attributes":{"name":"Name7"}} - ]} - """ - - Scenario: Create User - Not Found (Unknown) - When I post '{"data":{"type":"users","id":"user9","attributes":{"name":"9emaN"}}}' to "users" - Then I should see - """ - {"data":{"type":"users","id":"user9","attributes":{"name":"9emaN"}}} - """ - - Scenario: Create User - Not Found (Deleted) - When I post '{"data":{"type":"users","id":"user8","attributes":{"name":"8emaN"}}}' to "users" - Then I should see - """ - {"data":{"type":"users","id":"user8","attributes":{"name":"8emaN"}}} - """ - - Scenario: Create User - Found - When I post '{"data":{"type":"users","id":"user3","attributes":{"name":"3emaN"}}}' to "users" - Then I should see - """ - {"errors":[{"error":{"code":403, "msg":"Forbidden"}}]} - """ - - Scenario: Read User - Not Found (Unknown) - When I visit "users/user9" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read User - Not Found (Deleted) - When I visit "users/user8" - Then I should see - """ - {"errors":[{"error":{"code":404,"msg":"Not Found"}}]} - """ - - Scenario: Read User - Found - When I visit "users/user3" - Then I should see - """ - {"data":{"type":"users","id":"user3","attributes":{"name":"Name3"}}} - """ - - Scenario: Update User - Not Found (Unknown) - When I put '{"data":{"type":"users","id":"user9","attributes":{"name":"9emaN"}}}' to "users/user9" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update User - Not Found (Deleted) - When I put '{"data":{"type":"users","id":"user8","attributes":{"name":"8emaN"}}}' to "users/user8" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Update User - Found - When I put '{"data":{"type":"users","id":"user3","attributes":{"name":"3emaN"}}}' to "users/user3" - Then I should see - """ - {"data":{"type":"users","id":"user3","attributes":{"name":"3emaN"}}} - """ - - Scenario: Delete User - Not Found (Unknown) - When I delete "users/user9" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete User - Not Found (Deleted) - When I delete "users/user8" - Then I should see - """ - {"errors":[{"error":{"code":404, "msg":"Not Found"}}]} - """ - - Scenario: Delete User - Found - When I delete "users/user3" - Then I should see - """ - {"data":{"type":"users","id":"user3","attributes":{"name":"Name3"}}} - """ diff --git a/api/features/query_networks.feature b/api/features/query_networks.feature deleted file mode 100644 index 422df1a0..00000000 --- a/api/features/query_networks.feature +++ /dev/null @@ -1,26 +0,0 @@ -Feature: Query Networks - - Background: - Given user "Name" with credentials "user:password" - Given the following networks exist: - | id | cidr | deleted | - | 1 | 1.2.3.3/8 | f | - | 2 | 2.2.3.3/8 | t | - | 3 | 128.0.3.3/16 | t | - | 4 | 128.1.3.3/16 | f | - | 5 | 192.0.0.3/24 | f | - | 6 | 192.0.1.3/24 | t | - - Scenario: IP not contain by any network - When I visit "networks?ip=128.0.3.3" - Then I should see - """ - {"data":[]} - """ - - Scenario: IP contain by one network - When I visit "networks?ip=128.1.3.3" - Then I should see - """ - {"data":[{"attributes":{"access":"allow","cidr":"128.1.0.0/16"},"id":4,"type":"networks"}]} - """ diff --git a/api/features/step_definitions/clients_steps.rb b/api/features/step_definitions/clients_steps.rb deleted file mode 100644 index 14e348e5..00000000 --- a/api/features/step_definitions/clients_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Given("the following clients exist:") do |table| - table.hashes.each do |row| - Factory[:client, id: row["id"].to_i, name: row["name"]] - end -end diff --git a/api/features/step_definitions/collection_steps.rb b/api/features/step_definitions/collection_steps.rb deleted file mode 100644 index adaac7d9..00000000 --- a/api/features/step_definitions/collection_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Given("the following collections exist:") do |table| - table.hashes.each do |row| - Factory[:collection, uniqueIdentifier: row["id"], commonName: row["name"], dlpsDeleted: row["deleted"]] - end -end diff --git a/api/features/step_definitions/endpoint_steps.rb b/api/features/step_definitions/endpoint_steps.rb deleted file mode 100644 index 10544c60..00000000 --- a/api/features/step_definitions/endpoint_steps.rb +++ /dev/null @@ -1,21 +0,0 @@ -When("I post {string} to {string}") do |json, url| - post "/#{url}", json, "CONTENT_TYPE" => "application/json" -end - -When("I visit {string}") do |url| - get "/#{url}" -end - -When("I put {string} to {string}") do |json, url| - put "/#{url}", json, "CONTENT_TYPE" => "application/json" -end - -When("I delete {string}") do |url| - delete "/#{url}" -end - -Then("I should see") do |doc_string| - expected = doc_string - expected = JSON.parse(doc_string) unless doc_string.empty? - expect(JSON.parse(last_response.body)).to eq(expected) -end diff --git a/api/features/step_definitions/group_steps.rb b/api/features/step_definitions/group_steps.rb deleted file mode 100644 index 81a36211..00000000 --- a/api/features/step_definitions/group_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Given("the following groups exist:") do |table| - table.hashes.each do |row| - Factory[:group, uniqueIdentifier: row["id"].to_i, commonName: row["name"], dlpsDeleted: row["deleted"]] - end -end diff --git a/api/features/step_definitions/institution_steps.rb b/api/features/step_definitions/institution_steps.rb deleted file mode 100644 index 382fa553..00000000 --- a/api/features/step_definitions/institution_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Given("the following institutions exist:") do |table| - table.hashes.each do |row| - Factory[:institution, uniqueIdentifier: row["id"].to_i, organizationName: row["name"], dlpsDeleted: row["deleted"]] - end -end diff --git a/api/features/step_definitions/network_steps.rb b/api/features/step_definitions/network_steps.rb deleted file mode 100644 index 526bf9ca..00000000 --- a/api/features/step_definitions/network_steps.rb +++ /dev/null @@ -1,22 +0,0 @@ -Given("the following networks exist:") do |table| - table.hashes.each do |row| - ip = IPAddress.parse row["cidr"] - cidr = "0.0.0.0/0" - min = 0 - max = 0xFFFFFFFF - case ip.prefix - when 32 - cidr = ip.to_string - min = max = ip.to_u32 - when 31 - cidr = ip.first.to_string - min = ip.first.to_u32 - max = ip.last.to_u32 - else - cidr = ip.network.to_string - min = ip.network.to_u32 - max = ip.broadcast.to_u32 - end - Factory[:network, uniqueIdentifier: row["id"].to_i, dlpsCIDRAddress: cidr, dlpsAddressStart: min, dlpsAddressEnd: max, dlpsDeleted: row["deleted"]] - end -end diff --git a/api/features/step_definitions/user_steps.rb b/api/features/step_definitions/user_steps.rb deleted file mode 100644 index 32769054..00000000 --- a/api/features/step_definitions/user_steps.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "base64" - -Given("no user credentials") do -end - -Given("user credentials {string}") do |basic| - header "X-Auth", Base64.encode64(basic).to_s -end - -Given("user {string} with credentials {string}") do |name, credentials| - userid, password = credentials.split(":") - Factory[:user, userid: userid, surname: name, userPassword: password] - header "X-Auth", Base64.encode64(credentials).to_s -end - -Given("the following users exist:") do |table| - table.hashes.each do |row| - Factory[:user, userid: row["id"], surname: row["name"], dlpsDeleted: row["deleted"]] - end -end diff --git a/api/features/support/env.rb b/api/features/support/env.rb deleted file mode 100644 index 54dd5cdf..00000000 --- a/api/features/support/env.rb +++ /dev/null @@ -1,37 +0,0 @@ -require "./api" -require "rom-factory" -require "rack/test" -require "database_cleaner/sequel" - -Factory = ROM::Factory.configure do |config| - config.rom = Lauth::API::BDD.rom -end - -factories_dir = File.expand_path("../../../../lib/lauth/api/factories", __FILE__) -Dir[factories_dir + "/*.rb"].sort.each { |file| require file } - -include Rack::Test::Methods # standard:disable Style/MixinUsage - -def app - Lauth::API::APP.new -end - -BeforeAll do - DatabaseCleaner.strategy = :transaction -end - -AfterAll do - # puts "After All" -end - -Before do - # puts "Before" -end - -After do - # puts "After" -end - -Around do |scenario, block| - DatabaseCleaner.cleaning(&block) -end diff --git a/api/spec/repositories/client_spec.rb b/api/spec/repositories/client_spec.rb deleted file mode 100644 index 38d3a1f0..00000000 --- a/api/spec/repositories/client_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Client do - let(:repo) { described_class.new(Lauth::API::BDD.rom) } - - it "has no clients" do - expect(repo.index.count).to eq(0) - end - - describe "#client and #clients" do - let!(:client) { Factory[:client, id: 2] } - - it "contains one client" do - expect(repo.index.count).to eq(1) - end - - it "finds the new client" do - expect(repo.read(2).id).to eq(2) - end - - it "does NOT find an unknown client" do - expect(repo.read(1)).to be nil - end - end -end diff --git a/api/spec/repositories/collection_spec.rb b/api/spec/repositories/collection_spec.rb deleted file mode 100644 index dc259e08..00000000 --- a/api/spec/repositories/collection_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Collection do - let(:repo) { described_class.new(Lauth::API::BDD.rom) } - - it "has no collections" do - expect(repo.index.count).to eq(0) - end - - describe "#collection and #collections" do - let!(:new_collection) { Factory[:collection, uniqueIdentifier: "Identifier2"] } - let!(:deleted_collection) { Factory[:collection, uniqueIdentifier: "Identifier1", dlpsDeleted: "t"] } - - it "now has only one collection" do - expect(repo.index.count).to eq(1) - end - - it "finds the new collection" do - expect(repo.read("Identifier2").id).to eq("Identifier2") - end - - it "does NOT find the deleted collection" do - expect(repo.read("Identifier1")).to be nil - end - - it "does NOT find an unknown collection" do - expect(repo.read("Identifier3")).to be nil - end - end - - describe "searching for collection based on request URI" do - context "with a collection 'somecoll' hosted at '/s/somecoll'" do - let!(:coll) { Factory[:collection, uniqueIdentifier: "somecoll"] } - let!(:loc) { Factory[:location, coll: "somecoll", dlpsServer: "some.host", dlpsPath: "/s/somecoll%"] } - - it "finds the collection for a request to '/s/somecoll'" do - colls = repo.by_request_uri("some.host", "/s/somecoll") - expect(colls.first).to eq coll - end - - it "finds the collection for a request to '/s/somecoll/resource'" do - colls = repo.by_request_uri("some.host", "/s/somecoll/resource") - expect(colls.first).to eq coll - end - - it "does not find the collection for a request to '/s/some'" do - colls = repo.by_request_uri("some.host", "/s/some") - expect(colls).to be_empty - end - end - - context "with two collections, 'somecoll' and 'othercoll'" do - let!(:somecoll) { Factory[:collection, uniqueIdentifier: "somecoll"] } - let!(:someloc) { Factory[:location, coll: "somecoll", dlpsServer: "some.host", dlpsPath: "/s/somecoll%"] } - let!(:othercoll) { Factory[:collection, uniqueIdentifier: "othercoll"] } - let!(:otherloc) { Factory[:location, coll: "othercoll", dlpsServer: "some.host", dlpsPath: "/o/othercoll%"] } - - it "finds somecoll for a request to '/s/somecoll'" do - colls = repo.by_request_uri("some.host", "/s/somecoll") - expect(colls.first).to eq somecoll - end - - it "finds othercoll for a request to '/o/othercoll'" do - colls = repo.by_request_uri("some.host", "/o/othercoll") - expect(colls.first).to eq othercoll - end - end - end -end diff --git a/api/spec/repositories/group_spec.rb b/api/spec/repositories/group_spec.rb deleted file mode 100644 index ad07fa99..00000000 --- a/api/spec/repositories/group_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Group do - let(:repo) { described_class.new(Lauth::API::BDD.rom) } - - context "seeded root user group" do - it "has only one user group" do - expect(repo.index.count).to eq(1) - end - - it "has a root user group" do - expect(repo.index.one.id).to eq(0) - end - - it "finds the root user group by id" do - expect(repo.read(0).id).to eq(0) - end - - it "does NOT find a non-root user group by id" do - expect(repo.read(1)).to be nil - end - end - - describe "#group and #groups" do - let!(:new_group) { Factory[:group, uniqueIdentifier: 2] } - let!(:deleted_group) { Factory[:group, uniqueIdentifier: 1, dlpsDeleted: "t"] } - - it "now has only two user groups" do - expect(repo.index.count).to eq(2) - end - - it "finds the new user group" do - expect(repo.read(2).id).to eq(2) - end - - it "does NOT find the deleted user group" do - expect(repo.read(1)).to be nil - end - - it "does NOT find an unknown user group" do - expect(repo.read(3)).to be nil - end - end -end diff --git a/api/spec/repositories/institution_spec.rb b/api/spec/repositories/institution_spec.rb deleted file mode 100644 index 7f40500d..00000000 --- a/api/spec/repositories/institution_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Institution do - let(:repo) { described_class.new(Lauth::API::BDD.rom) } - - it "has no institutions" do - expect(repo.index.count).to eq(0) - end - - describe "#institution and #institutions" do - let!(:new_institution) { Factory[:institution, uniqueIdentifier: 2] } - let!(:deleted_institution) { Factory[:institution, uniqueIdentifier: 1, dlpsDeleted: "t"] } - - it "now has only one institution" do - expect(repo.index.count).to eq(1) - end - - it "finds the new institution" do - expect(repo.read(2).id).to eq(2) - end - - it "does NOT find the deleted institution" do - expect(repo.read(1)).to be nil - end - - it "does NOT find an unknown institution" do - expect(repo.read(3)).to be nil - end - end -end diff --git a/api/spec/repositories/location_spec.rb b/api/spec/repositories/location_spec.rb deleted file mode 100644 index c5d7a5ab..00000000 --- a/api/spec/repositories/location_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Location do - let(:locations) { described_class.new(Lauth::API::BDD.rom) } - - it "finds a saved location" do - Factory[:collection, uniqueIdentifier: "somecoll"] - loc = Factory[:location, coll: "somecoll"] - - expect(locations.root.first).to eq loc - end -end diff --git a/api/spec/repositories/network_spec.rb b/api/spec/repositories/network_spec.rb deleted file mode 100644 index f0cf9b6e..00000000 --- a/api/spec/repositories/network_spec.rb +++ /dev/null @@ -1,207 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Network do - let(:repo) { described_class.new(Lauth::API::BDD.rom) } - let(:created_document) do - { - "data" => { - "id" => 1, - "type" => "networks", - "attributes" => { - "cidr" => created_ip_address.to_string - } - } - } - end - let(:created_ip_address) { IPAddress.parse "192.0.0.3/24" } - let(:created_network) { repo.create(created_document) } - let(:updated_document) do - { - "data" => { - "id" => 1, - "type" => "networks", - "attributes" => { - "cidr" => updated_ip_address.to_string - } - } - } - end - let(:updated_ip_address) { IPAddress.parse "192.0.1.3/24" } - let(:updated_network) { repo.update(updated_document) } - let(:invalid_document) do - { - "data" => { - "id" => 1, - "type" => "networks", - "attributes" => { - } - } - } - end - - it "has no networks" do - expect(repo.index.count).to eq(0) - end - - describe "index and read" do - let!(:undeleted_network) { Factory[:network, uniqueIdentifier: 2] } - let!(:deleted_network) { Factory[:network, uniqueIdentifier: 1, dlpsDeleted: "t"] } - - it "now has only one network" do - expect(repo.index.count).to eq(1) - end - - it "finds the undeleted network" do - expect(repo.read(2).id).to eq(2) - end - - it "does NOT find the deleted network" do - expect(repo.read(1)).to be nil - end - - it "does NOT find an unknown network" do - expect(repo.read(3)).to be nil - end - end - - describe "create, update and delete" do - it "creates a network" do - created_network - expect(repo.read(created_network.id)).to eq(created_network) - end - - it "updates a network" do - created_network - updated_network - expect(repo.read(created_network.id)).to eq(updated_network) - end - - it "deletes a network" do - created_network - deleted_network = repo.delete(created_network.id) - expect(deleted_network).to eq(created_network) - expect(repo.read(created_network.id)).to be nil - end - end - - describe "ip network" do - context "singularity (one node)" do - let(:created_ip_address) { IPAddress.parse "192.0.0.3/32" } - let(:updated_ip_address) { IPAddress.parse "192.0.1.3/32" } - - it "cidr is start node address" do - expect(created_network.cidr).to eq("192.0.0.3/32") - expect(updated_network.cidr).to eq("192.0.1.3/32") - end - - it "minimum starts at node address" do - expect(created_network.minimum).to eq(created_ip_address.to_u32) - expect(updated_network.minimum).to eq(updated_ip_address.to_u32) - end - - it "maximum ends at node address" do - expect(created_network.maximum).to eq(created_ip_address.to_u32) - expect(updated_network.maximum).to eq(updated_ip_address.to_u32) - end - - context "include?" do - before { created_network } - - it "not found" do - created_network - expect(repo.include?(updated_ip_address).to_a).to be_empty - end - - it "found" do - created_network - expect(repo.include?(created_ip_address).to_a).to contain_exactly(created_network) - end - end - end - - context "degenerate (two nodes)" do - let(:created_ip_address) { IPAddress.parse "192.0.0.3/31" } - let(:updated_ip_address) { IPAddress.parse "192.0.1.3/31" } - - it "cidr is start node address" do - expect(created_network.cidr).to eq("192.0.0.2/31") - expect(updated_network.cidr).to eq("192.0.1.2/31") - end - - it "minimum starts at first node address" do - expect(created_network.minimum).to eq(created_ip_address.first.to_u32) - expect(updated_network.minimum).to eq(updated_ip_address.first.to_u32) - end - - it "maximum ends at last node address" do - expect(created_network.maximum).to eq(created_ip_address.last.to_u32) - expect(updated_network.maximum).to eq(updated_ip_address.last.to_u32) - end - - context "include?" do - before { created_network } - - it "not found" do - created_network - expect(repo.include?(updated_ip_address).to_a).to be_empty - end - - it "found" do - created_network - expect(repo.include?(created_ip_address).to_a).to contain_exactly(created_network) - end - end - end - - context "valid network (network, two or more nodes, broadcast" do - let(:created_ip_address) { IPAddress.parse "192.0.0.3/30" } - let(:updated_ip_address) { IPAddress.parse "192.0.1.3/30" } - - it "cidr is network address" do - expect(created_network.cidr).to eq("192.0.0.0/30") - expect(updated_network.cidr).to eq("192.0.1.0/30") - end - - it "minimum starts at network address" do - expect(created_network.minimum).to eq(created_ip_address.network.to_u32) - expect(updated_network.minimum).to eq(updated_ip_address.network.to_u32) - end - - it "maximum ends at broadcast address" do - expect(created_network.maximum).to eq(created_ip_address.broadcast.to_u32) - expect(updated_network.maximum).to eq(updated_ip_address.broadcast.to_u32) - end - - context "include?" do - before { created_network } - - it "not found" do - created_network - expect(repo.include?(updated_ip_address).to_a).to be_empty - end - - it "found" do - created_network - expect(repo.include?(created_ip_address).to_a).to contain_exactly(created_network) - end - end - end - end - - describe "change failures" do - it "fails to create on missing cidr attribute" do - expect(repo.create(invalid_document)).to be nil - end - - it "fails to update on missing cidr attribute" do - created_network - expect(repo.update(invalid_document)).to be nil - end - - it "fails to update a non-existing network" do - expect(repo.update(updated_document)).to be nil - end - - it "fails to delete a non-existing network" do - expect(repo.delete(1)).to be nil - end - end -end diff --git a/api/spec/repositories/user_spec.rb b/api/spec/repositories/user_spec.rb deleted file mode 100644 index 1c219d6c..00000000 --- a/api/spec/repositories/user_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -RSpec.describe Lauth::API::Repositories::User do - let(:repo) { described_class.new(Lauth::API::BDD.rom) } - - context "seeded root user" do - it "has only one user" do - expect(repo.index.count).to eq(1) - end - - it "has a root user" do - expect(repo.index.one.id).to eq("root") - end - - it "finds the root user by id" do - expect(repo.read("root").id).to eq("root") - end - - it "does NOT find a non-root user by id" do - expect(repo.read("user")).to be nil - end - end - - describe "#user and #users" do - let!(:new_user) { Factory[:user, userid: "new_user"] } - let!(:deleted_user) { Factory[:user, userid: "deleted_user", dlpsDeleted: "t"] } - - it "now has only two users" do - expect(repo.index.count).to eq(2) - end - - it "finds the new user" do - expect(repo.read("new_user").id).to eq("new_user") - end - - it "does NOT find the deleted user" do - expect(repo.read("deleted_user")).to be nil - end - - it "does NOT find an unknown user" do - expect(repo.read("unknown_user")).to be nil - end - end -end diff --git a/api/spec/spec_helper.rb b/api/spec/spec_helper.rb deleted file mode 100644 index 31d8509a..00000000 --- a/api/spec/spec_helper.rb +++ /dev/null @@ -1,121 +0,0 @@ -# This file was generated by the `rspec --init` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -require "./api" -require "rom-factory" -require "database_cleaner/sequel" -require "rack/test" -require "yabeda/rspec" - -Factory = ROM::Factory.configure do |config| - config.rom = Lauth::API::BDD.rom -end - -factories_dir = File.expand_path("../../../lib/lauth/api/factories", __FILE__) -Dir[factories_dir + "/*.rb"].sort.each { |file| require file } - -RSpec.configure do |config| - config.before(:suite) do - DatabaseCleaner.strategy = :transaction - end - - config.around(:each) do |example| - DatabaseCleaner.cleaning do - example.run - end - end - - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # This option will default to `:apply_to_host_groups` in RSpec 4 (and will - # have no way to turn it off -- the option exists only for backwards - # compatibility in RSpec 3). It causes shared context metadata to be - # inherited by the metadata hash of host groups and examples, rather than - # triggering implicit auto-inclusion in groups with matching metadata. - config.shared_context_metadata_behavior = :apply_to_host_groups - - # The settings below are suggested to provide a good initial experience - # with RSpec, but feel free to customize to your heart's content. - begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = ".rspec_status" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - # config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed - end -end diff --git a/api/spec/yabeda/create_count_spec.rb b/api/spec/yabeda/create_count_spec.rb deleted file mode 100644 index 3b5803db..00000000 --- a/api/spec/yabeda/create_count_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -RSpec.describe "Yabeda.lauth.create_count" do - include Rack::Test::Methods - - def app - Lauth::API::APP.new - end - - # let!(:user) { Factory[:user, userid: "user", userPassword: "password"] } - let(:headers) { {"HTTP_X_AUTH" => Base64.encode64("user:password").chomp} } - - it "resource clients" do - expect { post "/clients", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.create_count) - .with_tags(resource: "clients") - .by(1) - end - - it "resource collections" do - expect { post "/collections", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.create_count) - .with_tags(resource: "collections") - .by(1) - end - - it "resource groups" do - expect { post "/groups", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.create_count) - .with_tags(resource: "groups") - .by(1) - end - - it "resource institutions" do - expect { post "/institutions", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.create_count) - .with_tags(resource: "institutions") - .by(1) - end - - it "resource networks" do - expect { post "/networks", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.create_count) - .with_tags(resource: "networks") - .by(1) - end - - it "resource users" do - expect { post "/users", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.create_count) - .with_tags(resource: "users") - .by(1) - end -end diff --git a/api/spec/yabeda/delete_count_spec.rb b/api/spec/yabeda/delete_count_spec.rb deleted file mode 100644 index 5bf8dce5..00000000 --- a/api/spec/yabeda/delete_count_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -RSpec.describe "Yabeda.lauth.delete_count" do - include Rack::Test::Methods - - def app - Lauth::API::APP.new - end - - # let!(:user) { Factory[:user, userid: "user", userPassword: "password"] } - let(:headers) { {"HTTP_X_AUTH" => Base64.encode64("user:password").chomp} } - - it "resource clients" do - expect { delete "/clients/1", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.delete_count) - .with_tags(resource: "clients") - .by(1) - end - - it "resource collections" do - expect { delete "/collections/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.delete_count) - .with_tags(resource: "collections") - .by(1) - end - - it "resource groups" do - expect { delete "/groups/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.delete_count) - .with_tags(resource: "groups") - .by(1) - end - - it "resource institutions" do - expect { delete "/institutions/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.delete_count) - .with_tags(resource: "institutions") - .by(1) - end - - it "resource networks" do - expect { delete "/networks/1", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.delete_count) - .with_tags(resource: "networks") - .by(1) - end - - it "resource users" do - expect { delete "/users/user", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.delete_count) - .with_tags(resource: "users") - .by(1) - end -end diff --git a/api/spec/yabeda/index_count_spec.rb b/api/spec/yabeda/index_count_spec.rb deleted file mode 100644 index d599179d..00000000 --- a/api/spec/yabeda/index_count_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -RSpec.describe "Yabeda.lauth.index_count" do - include Rack::Test::Methods - - def app - Lauth::API::APP.new - end - - # let!(:user) { Factory[:user, userid: "user", userPassword: "password"] } - let(:headers) { {"HTTP_X_AUTH" => Base64.encode64("user:password").chomp} } - - it "resource clients" do - expect { get "/clients", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.index_count) - .with_tags(resource: "clients") - .by(1) - end - - it "resource collections" do - expect { get "/collections", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.index_count) - .with_tags(resource: "collections") - .by(1) - end - - it "resource groups" do - expect { get "/groups", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.index_count) - .with_tags(resource: "groups") - .by(1) - end - - it "resource institutions" do - expect { get "/institutions", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.index_count) - .with_tags(resource: "institutions") - .by(1) - end - - it "resource networks" do - expect { get "/networks", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.index_count) - .with_tags(resource: "networks") - .by(1) - end - - it "resource users" do - expect { get "/users", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.index_count) - .with_tags(resource: "users") - .by(1) - end -end diff --git a/api/spec/yabeda/read_count_spec.rb b/api/spec/yabeda/read_count_spec.rb deleted file mode 100644 index b6cf595f..00000000 --- a/api/spec/yabeda/read_count_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -RSpec.describe "Yabeda.lauth.read_count" do - include Rack::Test::Methods - - def app - Lauth::API::APP.new - end - - # let!(:user) { Factory[:user, userid: "user", userPassword: "password"] } - let(:headers) { {"HTTP_X_AUTH" => Base64.encode64("user:password").chomp} } - - it "resource clients" do - expect { get "/clients/1", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.read_count) - .with_tags(resource: "clients") - .by(1) - end - - it "resource collections" do - expect { get "/collections/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.read_count) - .with_tags(resource: "collections") - .by(1) - end - - it "resource groups" do - expect { get "/groups/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.read_count) - .with_tags(resource: "groups") - .by(1) - end - - it "resource institutions" do - expect { get "/institutions/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.read_count) - .with_tags(resource: "institutions") - .by(1) - end - - it "resource networks" do - expect { get "/networks/1", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.read_count) - .with_tags(resource: "networks") - .by(1) - end - - it "resource users" do - expect { get "/users/user", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.read_count) - .with_tags(resource: "users") - .by(1) - end -end diff --git a/api/spec/yabeda/update_count_spec.rb b/api/spec/yabeda/update_count_spec.rb deleted file mode 100644 index ddafdcff..00000000 --- a/api/spec/yabeda/update_count_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -RSpec.describe "Yabeda.lauth.update_count" do - include Rack::Test::Methods - - def app - Lauth::API::APP.new - end - - # let!(:user) { Factory[:user, userid: "user", userPassword: "password"] } - let(:headers) { {"HTTP_X_AUTH" => Base64.encode64("user:password").chomp} } - - it "resource clients" do - expect { put "/clients/1", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.update_count) - .with_tags(resource: "clients") - .by(1) - end - - it "resource collections" do - expect { put "/collections/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.update_count) - .with_tags(resource: "collections") - .by(1) - end - - it "resource groups" do - expect { put "/groups/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.update_count) - .with_tags(resource: "groups") - .by(1) - end - - it "resource institutions" do - expect { put "/institutions/michigan", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.update_count) - .with_tags(resource: "institutions") - .by(1) - end - - it "resource networks" do - expect { put "/networks/1", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.update_count) - .with_tags(resource: "networks") - .by(1) - end - - it "resource users" do - expect { put "/users/user", {}, headers } - .to increment_yabeda_counter(Yabeda.lauth.update_count) - .with_tags(resource: "users") - .by(1) - end -end diff --git a/cli/.envrc b/cli/.envrc deleted file mode 100644 index 234188db..00000000 --- a/cli/.envrc +++ /dev/null @@ -1 +0,0 @@ -PATH_add bin diff --git a/cli/.gitignore b/cli/.gitignore deleted file mode 100644 index 7dc345e8..00000000 --- a/cli/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -*.gem -*.rbc -/.config -/coverage/ -/InstalledFiles -/pkg/ -/spec/reports/ -/spec/examples.txt -.rspec_status -/test/tmp/ -/test/version_tmp/ -/tmp/ -.bash_history -.cache/ - -# Used by dotenv library to load environment variables. -.env - -# Ignore Byebug command history file. -.byebug_history - -## Documentation cache and generated files: -/.yardoc/ -/_yardoc/ -/doc/ -/rdoc/ - -## Environment normalization: -/.bundle/ -/vendor/bundle -/lib/bundler/man/ - diff --git a/cli/.rspec b/cli/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/cli/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/cli/.ruby-version b/cli/.ruby-version deleted file mode 100644 index ef538c28..00000000 --- a/cli/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -3.1.2 diff --git a/cli/.standard.yml b/cli/.standard.yml deleted file mode 100644 index 41caa771..00000000 --- a/cli/.standard.yml +++ /dev/null @@ -1,3 +0,0 @@ -# For available configuration options, see: -# https://github.com/testdouble/standard - diff --git a/cli/Dockerfile b/cli/Dockerfile deleted file mode 100644 index 5872ff69..00000000 --- a/cli/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -ARG RUBY_VERSION=3.2.2 -FROM ruby:${RUBY_VERSION} - -ARG BUNDLER_VERSION=2.4.21 -ARG UNAME=lauth -ARG UID=1000 -ARG GID=1000 - -LABEL maintainer="dla-staff@umich.edu" - -# Install Vim (optional) -RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ - default-mysql-client \ - vim-tiny - -RUN gem install bundler:${BUNDLER_VERSION} - -RUN groupadd -g ${GID} -o ${UNAME} -RUN useradd -m -d /lauth -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME} -RUN chown -R ${UID}:${GID} /usr/local/bundle -RUN mkdir -p /lauth/cli /lauth/lib -RUN mkdir -p /gems && chown ${UID}:${GID} /gems - -ENV BUNDLE_PATH /gems - -WORKDIR /lauth/cli -COPY cli/Gemfile* /lauth/cli -RUN chown ${UID}:${GID} /lauth/cli/Gemfile* - -USER $UNAME - -RUN bundle install - -COPY cli/ /lauth/cli -COPY lib/ /lauth/lib - -CMD ["sleep", "infinity"] diff --git a/cli/Dockerfile.prod b/cli/Dockerfile.prod deleted file mode 100644 index cb9ea2ad..00000000 --- a/cli/Dockerfile.prod +++ /dev/null @@ -1,45 +0,0 @@ -ARG RUBY_VERSION=3.1 -FROM ruby:${RUBY_VERSION} - -ARG BUNDLER_VERSION=2.3 -ARG UNAME=lauth -ARG UID=1001 -ARG GID=1001 - -LABEL maintainer="dla-staff@umich.edu" - -# Install Vim (optional) -RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ - default-mysql-client \ - vim-tiny - -RUN gem install bundler:${BUNDLER_VERSION} - -RUN groupadd -g ${GID} -o ${UNAME} -RUN useradd -m -d /lauth -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME} -RUN mkdir -p /lauth/api -RUN mkdir -p /lauth/cli -RUN mkdir -p /lauth/db -RUN mkdir -p /lauth/lib -RUN mkdir -p /lauth/gems - -ENV BUNDLE_PATH /lauth/gems - -WORKDIR /lauth/api -COPY api/Gemfile* /lauth/api -RUN bundle install - -WORKDIR /lauth/cli -COPY cli/Gemfile* /lauth/cli -RUN bundle install - -COPY api/ /lauth/api -COPY cli/ /lauth/cli -COPY db/ /lauth/db -COPY lib/ /lauth/lib - -RUN chown -R ${UID}:${GID} /lauth - -USER $UNAME - -CMD ["sleep", "infinity"] diff --git a/cli/Gemfile b/cli/Gemfile deleted file mode 100644 index 3548ff73..00000000 --- a/cli/Gemfile +++ /dev/null @@ -1,20 +0,0 @@ -source "https://rubygems.org" - -gem "dotenv", "~> 2.7.6" -gem "gli" -gem "ipaddress" -gem "mysql2", "~> 0.5.4" -gem "rom", "~> 5.2.6" -gem "rom-sql", "~> 3.5.0" -gem "rom-http", git: "https://github.com/rom-rb/rom-http", ref: "f0507e52ba5f39a42ccfd24b0b6b88b86984c8de" - -# testing - -gem "cucumber", "~> 8.0.0" -gem "database_cleaner-sequel" -gem "rack-test" -gem "rake" -gem "rom-factory" -gem "rspec", "~> 3.11" -gem "sequel" -gem "standard", "~> 1.12" diff --git a/cli/Gemfile.lock b/cli/Gemfile.lock deleted file mode 100644 index f2ad1a5f..00000000 --- a/cli/Gemfile.lock +++ /dev/null @@ -1,194 +0,0 @@ -GIT - remote: https://github.com/rom-rb/rom-http - revision: f0507e52ba5f39a42ccfd24b0b6b88b86984c8de - ref: f0507e52ba5f39a42ccfd24b0b6b88b86984c8de - specs: - rom-http (0.8.0) - addressable (~> 2.6) - concurrent-ruby (~> 1.1) - dry-configurable (~> 0.6) - dry-core (~> 0.4) - dry-equalizer (~> 0.2) - rom (~> 5.0, >= 5.0.1) - -GEM - remote: https://rubygems.org/ - specs: - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) - ast (2.4.2) - builder (3.2.4) - concurrent-ruby (1.1.10) - cucumber (8.0.0) - builder (~> 3.2, >= 3.2.4) - cucumber-ci-environment (~> 9.0, >= 9.0.4) - cucumber-core (~> 11.0, >= 11.0.0) - cucumber-cucumber-expressions (~> 15.1, >= 15.1.1) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-html-formatter (~> 19.1, >= 19.1.0) - cucumber-messages (~> 18.0, >= 18.0.0) - diff-lcs (~> 1.5, >= 1.5.0) - mime-types (~> 3.4, >= 3.4.1) - multi_test (~> 1.1, >= 1.1.0) - sys-uname (~> 1.2, >= 1.2.2) - cucumber-ci-environment (9.1.0) - cucumber-core (11.0.0) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-tag-expressions (~> 4.1, >= 4.1.0) - cucumber-cucumber-expressions (15.2.0) - cucumber-gherkin (23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-html-formatter (19.2.0) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-messages (18.0.0) - cucumber-tag-expressions (4.1.0) - database_cleaner-core (2.0.1) - database_cleaner-sequel (2.0.2) - database_cleaner-core (~> 2.0.0) - sequel - diff-lcs (1.5.0) - dotenv (2.7.6) - dry-configurable (0.16.1) - dry-core (~> 0.6) - zeitwerk (~> 2.6) - dry-container (0.11.0) - concurrent-ruby (~> 1.0) - dry-core (0.8.1) - concurrent-ruby (~> 1.0) - dry-equalizer (0.3.0) - dry-inflector (0.3.0) - dry-initializer (3.1.1) - dry-logic (1.2.0) - concurrent-ruby (~> 1.0) - dry-core (~> 0.5, >= 0.5) - dry-struct (1.4.0) - dry-core (~> 0.5, >= 0.5) - dry-types (~> 1.5) - ice_nine (~> 0.11) - dry-types (1.5.1) - concurrent-ruby (~> 1.0) - dry-container (~> 0.3) - dry-core (~> 0.5, >= 0.5) - dry-inflector (~> 0.1, >= 0.1.2) - dry-logic (~> 1.0, >= 1.0.2) - faker (2.23.0) - i18n (>= 1.8.11, < 2) - ffi (1.15.5) - gli (2.21.0) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - ice_nine (0.11.2) - ipaddress (0.8.3) - json (2.6.2) - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - multi_test (1.1.0) - mysql2 (0.5.4) - parallel (1.22.1) - parser (3.1.2.1) - ast (~> 2.4.1) - public_suffix (5.0.0) - rack (3.0.0) - rack-test (2.0.2) - rack (>= 1.3) - rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.6.0) - rexml (3.2.5) - rom (5.2.6) - rom-changeset (~> 5.2, >= 5.2.3) - rom-core (~> 5.2, >= 5.2.5) - rom-repository (~> 5.2, >= 5.2.2) - rom-changeset (5.2.3) - dry-core (~> 0.4) - rom-core (~> 5.2) - transproc (~> 1.0, >= 1.1.0) - rom-core (5.2.6) - concurrent-ruby (~> 1.1) - dry-container (~> 0.7) - dry-core (~> 0.4) - dry-equalizer (~> 0.2) - dry-inflector (~> 0.1) - dry-initializer (~> 3.0, >= 3.0.1) - dry-struct (~> 1.0) - dry-types (~> 1.0) - transproc (~> 1.0, >= 1.1.0) - rom-factory (0.10.2) - dry-configurable (~> 0.7) - dry-core (~> 0.4) - faker (>= 1.7, < 3.0) - rom-core (~> 5.0) - rom-repository (5.2.2) - dry-core (~> 0.4) - dry-initializer (~> 3.0, >= 3.0.1) - rom-core (~> 5.2, >= 5.2.2) - rom-sql (3.5.0) - dry-core (~> 0.5, >= 0.5) - dry-types (~> 1.0) - rom (~> 5.2, >= 5.2.1) - sequel (>= 4.49) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.1) - rubocop (1.35.1) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.1.2.1) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.20.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.21.0) - parser (>= 3.1.1.0) - rubocop-performance (1.14.3) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - ruby-progressbar (1.11.0) - sequel (5.61.0) - standard (1.16.1) - rubocop (= 1.35.1) - rubocop-performance (= 1.14.3) - sys-uname (1.2.2) - ffi (~> 1.1) - transproc (1.1.1) - unicode-display_width (2.3.0) - zeitwerk (2.6.1) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - x86_64-linux - -DEPENDENCIES - cucumber (~> 8.0.0) - database_cleaner-sequel - dotenv (~> 2.7.6) - gli - ipaddress - mysql2 (~> 0.5.4) - rack-test - rake - rom (~> 5.2.6) - rom-factory - rom-http! - rom-sql (~> 3.5.0) - rspec (~> 3.11) - sequel - standard (~> 1.12) - -BUNDLED WITH - 2.4.21 diff --git a/cli/LICENSE b/cli/LICENSE deleted file mode 100644 index b7af7b25..00000000 --- a/cli/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2022, University of Michigan Library -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cli/README.md b/cli/README.md deleted file mode 100644 index d8dac2f4..00000000 --- a/cli/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# lauth-cli - Library Authorization CLI - -A command-line interface (CLI) for managing data in the Library Authorization -system. - -## Tools used for implementation: - - - [> gli](http://davetron5000.github.io/gli/) - Git Like Interface is the easy way to make command-suite CLI apps. - - [ROM](https://rom-rb.org/) - Ruby Object Mapper is an open-source persistence and mapping toolkit for Ruby built for speed and simplicity. - -## Configuration File - -The configuration file essentially stores command line option values to use as defaults when not specified by the user. The command `initconfig` that will create an initial version of the configuration file. - -```shell -./bin/lauth --url http://localhost:9292 --username=lauth --password=lauth initconfig -``` -The file `.lauth.rc` will be located in the user's home directory based on the value of the HOME environment variable. The next time you run `./bin/lauth`, the values for --url, --password, and --username will be defaulted to the values you specified when you ran `initconfig`. Of course, you can edit this file to make changes; it's just a simple YAML file. - -[RDoc](lauth.rdoc) diff --git a/cli/app/create.rb b/cli/app/create.rb deleted file mode 100644 index 0f4bf834..00000000 --- a/cli/app/create.rb +++ /dev/null @@ -1,152 +0,0 @@ -module Lauth - module CLI - module APP - desc "Create Resource" - arg_name "Resource" - command :create do |create| - create.desc "Create Client" - create.long_desc %( - Attributes are a comma separated list of colon separated key value pairs. - - name: - - e.g. name:wolverine,year:1817,city:"Ann Arbor",state:Michigan - ) - create.arg "", type: Hash - create.command :client do |client| - client.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - attributes = accepts[Hash].call(args[0]) - - repo = Lauth::CLI::Repositories::Client.new($rom) # standard:disable Style/GlobalVars - created_client = repo.create(attributes) - - puts "#{created_client.id}#{$separator}#{created_client.name}" if created_client # standard:disable Style/GlobalVars - end - end - - create.desc "Create Collection" - create.long_desc %( - Attributes are a comma separated list of colon separated key value pairs. - - name: - - e.g. name:wolverine,year:1817,city:"Ann Arbor",state:Michigan - ) - create.arg "" - create.arg "", type: Hash - create.command :collection do |collection| - collection.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Collection.new($rom) # standard:disable Style/GlobalVars - created_collection = repo.create(id, attributes) - - puts "#{created_collection.id}#{$separator}#{created_collection.name}" if created_collection # standard:disable Style/GlobalVars - end - end - - create.desc "Create Group" - create.long_desc %( - Attributes are a comma separated list of colon separated key value pairs. - - name: - - e.g. name:wolverine,year:1817,city:"Ann Arbor",state:Michigan - ) - create.arg "" - create.arg "", type: Hash - create.command :group do |group| - group.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Group.new($rom) # standard:disable Style/GlobalVars - created_group = repo.create(id, attributes) - - puts "#{created_group.id}#{$separator}#{created_group.name}" if created_group # standard:disable Style/GlobalVars - end - end - - create.desc "Create Institution" - create.long_desc %( - Attributes are a comma separated list of colon separated key value pairs. - - name: - - e.g. name:wolverine,year:1817,city:"Ann Arbor",state:Michigan - ) - create.arg "" - create.arg "", type: Hash - create.command :institution do |institution| - institution.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Institution.new($rom) # standard:disable Style/GlobalVars - created_institution = repo.create(id, attributes) - - puts "#{created_institution.id}#{$separator}#{created_institution.name}" if created_institution # standard:disable Style/GlobalVars - end - end - - create.desc "Create Network" - create.long_desc %( - Attributes are a comma separated list of colon separated key value pairs. - - name: - - e.g. name:wolverine,year:1817,city:"Ann Arbor",state:Michigan - ) - create.arg "" - create.arg "", type: Hash - create.command :network do |network| - network.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Network.new($rom) # standard:disable Style/GlobalVars - created_network = repo.create(id, attributes) - - puts "#{created_network.id}#{$separator}#{created_network.cidr}#{$separator}#{created_network.access}" if created_network # standard:disable Style/GlobalVars - end - end - - create.desc "Create User" - create.long_desc %( - Attributes are a comma separated list of colon separated key value pairs. - - name: - - e.g. name:wolverine,year:1817,city:"Ann Arbor",state:Michigan - ) - create.arg "" - create.arg "", type: Hash - create.command :user do |user| - # user.desc "User ID" - user.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::User.new($rom) # standard:disable Style/GlobalVars - created_user = repo.create(id, attributes) - - puts "#{created_user.id}#{$separator}#{created_user.name}" if created_user # standard:disable Style/GlobalVars - end - end - end - end - end -end diff --git a/cli/app/delete.rb b/cli/app/delete.rb deleted file mode 100644 index a60287fc..00000000 --- a/cli/app/delete.rb +++ /dev/null @@ -1,99 +0,0 @@ -module Lauth - module CLI - module APP - desc "Delete Resource" - arg_name "Resource" - command :delete do |delete| - delete.desc "Delete Client" - delete.arg_name "id" - delete.command :client do |client| - client.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Client.new($rom) # standard:disable Style/GlobalVars - deleted_client = repo.delete(id) - - puts "#{deleted_client.id}#{$separator}#{deleted_client.name}" if deleted_client # standard:disable Style/GlobalVars - end - end - - delete.desc "Delete Collection" - delete.arg_name "id" - delete.command :collection do |collection| - collection.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Collection.new($rom) # standard:disable Style/GlobalVars - deleted_collection = repo.delete(id) - - puts "#{deleted_collection.id}#{$separator}#{deleted_collection.name}" if deleted_collection # standard:disable Style/GlobalVars - end - end - - delete.desc "Delete Group" - delete.arg_name "id" - delete.command :group do |group| - group.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Group.new($rom) # standard:disable Style/GlobalVars - deleted_group = repo.delete(id) - - puts "#{deleted_group.id}#{$separator}#{deleted_group.name}" if deleted_group # standard:disable Style/GlobalVars - end - end - - delete.desc "Delete Institution" - delete.arg_name "id" - delete.command :institution do |institution| - institution.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Institution.new($rom) # standard:disable Style/GlobalVars - deleted_institution = repo.delete(id) - - puts "#{deleted_institution.id}#{$separator}#{deleted_institution.name}" if deleted_institution # standard:disable Style/GlobalVars - end - end - - delete.desc "Delete Network" - delete.arg_name "id" - delete.command :network do |network| - network.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Network.new($rom) # standard:disable Style/GlobalVars - deleted_network = repo.delete(id) - - puts "#{deleted_network.id}#{$separator}#{deleted_network.cidr}#{$separator}#{deleted_network.access}" if deleted_network # standard:disable Style/GlobalVars - end - end - - delete.desc "Delete User" - delete.arg_name "id" - delete.command :user do |user| - user.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::User.new($rom) # standard:disable Style/GlobalVars - deleted_user = repo.delete(id) - - puts "#{deleted_user.id}#{$separator}#{deleted_user.name}" if deleted_user # standard:disable Style/GlobalVars - end - end - end - end - end -end diff --git a/cli/app/ipv4.rb b/cli/app/ipv4.rb deleted file mode 100644 index 70131211..00000000 --- a/cli/app/ipv4.rb +++ /dev/null @@ -1,51 +0,0 @@ -module Lauth - module CLI - module APP - desc "Internet Protocol Version 4 Utility" - long_desc %( - lauth ipv4 128.32.0.127 - - lauth ipv4 128.32.0.127/16 - - lauth ipv4 128.32.0.127/255.255.255.0 - ) - arg_name "[/(|)]" - command :ipv4 do |ipv4| - ipv4.desc "hello" - ipv4.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args[0] - ip = IPAddress.parse(args[0]) - ip_count = ip.broadcast.to_u32 - ip.network.to_u32 + 1 - host_count = ip.last.to_u32 - ip.first.to_u32 + 1 - puts "{" - puts " 'cidr' : '#{ip.to_string}'" - puts " 'address' : '#{ip.address}'" - puts " 'prefix' : #{ip.prefix}" - puts " 'netmask' : '#{ip.netmask}'" - case host_count - when 1, 2 # Bug in IPAddress class - should probably create an issue or PR in https://github.com/ipaddress-gem/ipaddress - if ip_count == 4 - puts " 'network' : '#{ip.network}'" - puts " 'first_host' : '#{ip.first}'" - puts " 'last_host' : '#{ip.last}'" - puts " 'broadcast' : '#{ip.broadcast}'" - else - puts " 'network' : '#{ip.first}'" - puts " 'first_host' : '#{ip.first}'" - puts " 'last_host' : '#{ip.last}'" - puts " 'broadcast' : '#{ip.last}'" - end - else - puts " 'network' : '#{ip.network}'" - puts " 'first_host' : '#{ip.first}'" - puts " 'last_host' : '#{ip.last}'" - puts " 'broadcast' : '#{ip.broadcast}'" - end - puts " 'host_count' : #{host_count}" - puts "}" - end - end - end - end -end diff --git a/cli/app/list.rb b/cli/app/list.rb deleted file mode 100644 index e2b8b234..00000000 --- a/cli/app/list.rb +++ /dev/null @@ -1,108 +0,0 @@ -module Lauth - module CLI - module APP - desc "List Resource" - arg_name "Resource" - command :list do |list| - desc "Page List Size" - list.flag [:pagesize], arg_name: "page_size", default_value: 10 - - desc "Page Number" - list.flag [:pagenumber], arg_name: "page_number", default_value: -1 - - desc "Regulare Expression" - list.flag [:regex], arg_name: "regular_expression", default_value: ".*" - - list.desc "List Clients" - list.command :clients do |clients| - clients.action do |global_options, options, args| - # If you have any errors, just raise them - # raise "that command made no sense" unless args - - repo = Lauth::CLI::Repositories::Client.new($rom) # standard:disable Style/GlobalVars - listed_clients = repo.index - - listed_clients.each do |client| - puts "#{client.id}#{$separator}#{client.name}" # standard:disable Style/GlobalVars - end - end - end - - list.desc "List Collections" - list.command :collections do |collections| - collections.action do |global_options, options, args| - # If you have any errors, just raise them - # raise "that command made no sense" unless args - - repo = Lauth::CLI::Repositories::Collection.new($rom) # standard:disable Style/GlobalVars - listed_collections = repo.index - - listed_collections.each do |collection| - puts "#{collection.id}#{$separator}#{collection.name}" # standard:disable Style/GlobalVars - end - end - end - - list.desc "List Groups" - list.command :groups do |groups| - groups.action do |global_options, options, args| - # If you have any errors, just raise them - # raise "that command made no sense" unless args - - repo = Lauth::CLI::Repositories::Group.new($rom) # standard:disable Style/GlobalVars - listed_groups = repo.index - - listed_groups.each do |group| - puts "#{group.id}#{$separator}#{group.name}" # standard:disable Style/GlobalVars - end - end - end - - list.desc "List Institutions" - list.command :institutions do |institutions| - institutions.action do |global_options, options, args| - # If you have any errors, just raise them - # raise "that command made no sense" unless args - - repo = Lauth::CLI::Repositories::Institution.new($rom) # standard:disable Style/GlobalVars - listed_institutions = repo.index - - listed_institutions.each do |institution| - puts "#{institution.id}#{$separator}#{institution.name}" # standard:disable Style/GlobalVars - end - end - end - - list.desc "List Networks" - list.command :networks do |networks| - networks.action do |global_options, options, args| - # If you have any errors, just raise them - # raise "that command made no sense" unless args - - repo = Lauth::CLI::Repositories::Network.new($rom) # standard:disable Style/GlobalVars - listed_networks = repo.index - - listed_networks.each do |network| - puts "#{network.id}#{$separator}#{network.cidr}#{$separator}#{network.access}" # standard:disable Style/GlobalVars - end - end - end - - list.desc "List Users" - list.command :users do |users| - users.action do |global_options, options, args| - # If you have any errors, just raise them - # raise "that command made no sense" unless args - - repo = Lauth::CLI::Repositories::User.new($rom) # standard:disable Style/GlobalVars - listed_users = repo.index - - listed_users.each do |user| - puts "#{user.id}#{$separator}#{user.name}" # standard:disable Style/GlobalVars - end - end - end - end - end - end -end diff --git a/cli/app/query.rb b/cli/app/query.rb deleted file mode 100644 index fa0d9fe9..00000000 --- a/cli/app/query.rb +++ /dev/null @@ -1,26 +0,0 @@ -module Lauth - module CLI - module APP - desc "Query Resource" - arg_name "Resource" - command :query do |query| - query.desc "Query Network" - query.arg_name "" - query.command :networks do |networks| - networks.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - ip = IPAddress.parse args[0] - - repo = Lauth::CLI::Repositories::Network.new($rom) # standard:disable Style/GlobalVars - networks = repo.query(ip) - - networks.each do |network| - puts "#{network.id}#{$separator}#{network.cidr}" # standard:disable Style/GlobalVars - end - end - end - end - end - end -end diff --git a/cli/app/read.rb b/cli/app/read.rb deleted file mode 100644 index 994094f1..00000000 --- a/cli/app/read.rb +++ /dev/null @@ -1,99 +0,0 @@ -module Lauth - module CLI - module APP - desc "Read Resource" - arg_name "Resource" - command :read do |read| - read.desc "Read Client" - read.arg_name "id" - read.command :client do |client| - client.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Client.new($rom) # standard:disable Style/GlobalVars - read_client = repo.read(id).one - - puts "#{read_client.id}#{$separator}#{read_client.name}" if read_client # standard:disable Style/GlobalVars - end - end - - read.desc "Read Collection" - read.arg_name "id" - read.command :collection do |collection| - collection.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Collection.new($rom) # standard:disable Style/GlobalVars - read_collection = repo.read(id).one - - puts "#{read_collection.id}#{$separator}#{read_collection.name}" if read_collection # standard:disable Style/GlobalVars - end - end - - read.desc "Read Group" - read.arg_name "id" - read.command :group do |group| - group.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Group.new($rom) # standard:disable Style/GlobalVars - read_group = repo.read(id).one - - puts "#{read_group.id}#{$separator}#{read_group.name}" if read_group # standard:disable Style/GlobalVars - end - end - - read.desc "Read Institution" - read.arg_name "id" - read.command :institution do |institution| - institution.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Institution.new($rom) # standard:disable Style/GlobalVars - read_institution = repo.read(id).one - - puts "#{read_institution.id}#{$separator}#{read_institution.name}" if read_institution # standard:disable Style/GlobalVars - end - end - - read.desc "Read Network" - read.arg_name "id" - read.command :network do |network| - network.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::Network.new($rom) # standard:disable Style/GlobalVars - read_network = repo.read(id).one - - puts "#{read_network.id}#{$separator}#{read_network.cidr}#{$separator}#{read_network.access}" if read_network # standard:disable Style/GlobalVars - end - end - - read.desc "Read User" - read.arg_name "id" - read.command :user do |user| - user.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - - repo = Lauth::CLI::Repositories::User.new($rom) # standard:disable Style/GlobalVars - read_user = repo.read(id).one - - puts "#{read_user.id}#{$separator}#{read_user.name}" if read_user # standard:disable Style/GlobalVars - end - end - end - end - end -end diff --git a/cli/app/update.rb b/cli/app/update.rb deleted file mode 100644 index bf573067..00000000 --- a/cli/app/update.rb +++ /dev/null @@ -1,117 +0,0 @@ -module Lauth - module CLI - module APP - desc "Update Resource" - long_desc %( - Attributes are a comma separated list of colon separated key value pairs. - - name:wolverine,year:1817,city:"Ann Arbor",state:Michigan - ) - arg_name "Resource" - command :update do |update| - update.desc "Update Client" - update.arg "id" - update.arg "attributes", type: Hash - update.command :client do |client| - client.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Client.new($rom) # standard:disable Style/GlobalVars - updated_client = repo.update(id, attributes) - - puts "#{updated_client.id}#{$separator}#{updated_client.name}" if updated_client # standard:disable Style/GlobalVars - end - end - - update.desc "Update Collection" - update.arg "id" - update.arg "attributes", type: Hash - update.command :collection do |collection| - collection.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Collection.new($rom) # standard:disable Style/GlobalVars - updated_collection = repo.update(id, attributes) - - puts "#{updated_collection.id}#{$separator}#{updated_collection.name}" if updated_collection # standard:disable Style/GlobalVars - end - end - - update.desc "Update Group" - update.arg "id" - update.arg "attributes", type: Hash - update.command :group do |group| - group.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Group.new($rom) # standard:disable Style/GlobalVars - updated_group = repo.update(id, attributes) - - puts "#{updated_group.id}#{$separator}#{updated_group.name}" if updated_group # standard:disable Style/GlobalVars - end - end - - update.desc "Update Institution" - update.arg "id" - update.arg "attributes", type: Hash - update.command :institution do |institution| - institution.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Institution.new($rom) # standard:disable Style/GlobalVars - updated_institution = repo.update(id, attributes) - - puts "#{updated_institution.id}#{$separator}#{updated_institution.name}" if updated_institution # standard:disable Style/GlobalVars - end - end - - update.desc "Update Network" - update.arg "id" - update.arg "attributes", type: Hash - update.command :network do |network| - network.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::Network.new($rom) # standard:disable Style/GlobalVars - updated_network = repo.update(id, attributes) - - puts "#{updated_network.id}#{$separator}#{updated_network.cidr}#{$separator}#{updated_network.access}" if updated_network # standard:disable Style/GlobalVars - end - end - - update.desc "Update User" - update.arg "id" - update.arg "attributes", type: Hash - update.command :user do |user| - # user.desc "User ID" - user.action do |global_options, options, args| - # If you have any errors, just raise them - raise "that command made no sense" unless args - id = args[0] - attributes = accepts[Hash].call(args[1]) - - repo = Lauth::CLI::Repositories::User.new($rom) # standard:disable Style/GlobalVars - updated_user = repo.update(id, attributes) - - puts "#{updated_user.id}#{$separator}#{updated_user.name}" if updated_user # standard:disable Style/GlobalVars - end - end - end - end - end -end diff --git a/cli/bin/cucumber b/cli/bin/cucumber deleted file mode 100755 index 9cb3ddb1..00000000 --- a/cli/bin/cucumber +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'cucumber' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -bundle_binstub = File.expand_path("../bundle", __FILE__) - -if File.file?(bundle_binstub) - if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300)) - load(bundle_binstub) - else - abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. -Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") - end -end - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("cucumber", "cucumber") diff --git a/cli/bin/lauth b/cli/bin/lauth deleted file mode 100755 index 367107a2..00000000 --- a/cli/bin/lauth +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby -require "bundler/setup" -require_relative "../cli" -# puts $LOAD_PATH.unshift(File.expand_path(".", __FILE__)) -exit Lauth::CLI::APP.run(ARGV) diff --git a/cli/bin/rspec b/cli/bin/rspec deleted file mode 100755 index 4305353d..00000000 --- a/cli/bin/rspec +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'rspec' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -bundle_binstub = File.expand_path("../bundle", __FILE__) - -if File.file?(bundle_binstub) - if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300)) - load(bundle_binstub) - else - abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. -Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") - end -end - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("rspec-core", "rspec") diff --git a/cli/bin/standardrb b/cli/bin/standardrb deleted file mode 100755 index fe07d50b..00000000 --- a/cli/bin/standardrb +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'standardrb' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -bundle_binstub = File.expand_path("../bundle", __FILE__) - -if File.file?(bundle_binstub) - if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300)) - load(bundle_binstub) - else - abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. -Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") - end -end - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("standard", "standardrb") diff --git a/cli/cli.rb b/cli/cli.rb deleted file mode 100644 index cad72957..00000000 --- a/cli/cli.rb +++ /dev/null @@ -1,87 +0,0 @@ -require "gli" -require "base64" -require "ipaddress" - -$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__)) -require "lauth" - -$LOAD_PATH.unshift(File.expand_path("..", __FILE__)) -# commands_from("app") - -module Lauth - module CLI - module APP - extend GLI::App - - config_file ".lauth.rc" - - program_desc "A command-line interface (CLI) for managing data in the Library Authorization system." - - subcommand_option_handling :normal - arguments :strict - - accept(Hash) do |value| - result = {} - value.split(",").each do |pair| - k, v = pair.split(":") - result[k.to_sym] = v - end - result - end - - desc "Verbose" - switch [:v, :verbose] - - desc "Headers" - switch [:h, :headers] - - desc "Lauth API URL" - flag [:r, :route], arg_name: "route", default_value: "http://127.0.0.1:9292" - - desc "Separator" - flag [:s, :separator], arg_name: "{comma, tab}", default_value: "comma", must_match: %w[comma tab] - - desc "Authorized user name" - flag [:u, :user], arg_name: "user", default_value: "lauth" - - desc "Authorized user password" - flag [:p, :password], arg_name: "password", default_value: "lauth", mask: true - - commands_from("app") - - pre do |global, command, options, args| - # Pre logic here - # Return true to proceed; false to abort and not call the - # chosen command - # Use skips_pre before a command to skip this block - # on that command only - credentials = Base64.encode64("#{global[:user]}:#{global[:password]}").chomp - - $rom = ::ROM.container(:http, uri: global[:route], headers: {X_AUTH: credentials}, handlers: :handlers) do |config| # standard:disable Style/GlobalVars - config.auto_registration("../lib/lauth/cli/rom", namespace: "Lauth::CLI::ROM") - end - - $separator = case global[:separator] # standard:disable Style/GlobalVars - when "comma" - "," - when "tab" - "\t" - end - - true - end - - post do |global, command, options, args| - # Post logic here - # Use skips_post before a command to skip this - # block on that command only - end - - on_error do |exception| - # Error logic here - # return false to skip default error handling - true - end - end - end -end diff --git a/cli/cucumber.yml b/cli/cucumber.yml deleted file mode 100644 index 16f9a813..00000000 --- a/cli/cucumber.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -default: --publish-quiet diff --git a/cli/features/authorized.feature b/cli/features/authorized.feature deleted file mode 100644 index 3aef8069..00000000 --- a/cli/features/authorized.feature +++ /dev/null @@ -1,25 +0,0 @@ -Feature: Authorized - - Background: - Given user "Name" with id "id" and password "password" - - Scenario: Unknown User - When I enter lauth -u "di" -p "password" "read user id" - Then I should see - """ - error: 401 "Unauthorized" - """ - - Scenario: Wrong Password - When I enter lauth -u "id" -p "drowssap" "read user id" - Then I should see - """ - error: 401 "Unauthorized" - """ - - Scenario: Correct Password - When I enter lauth -u "id" -p "password" "read user id" - Then I should see - """ - id,Name - """ diff --git a/cli/features/crud/clients.feature b/cli/features/crud/clients.feature deleted file mode 100644 index 57400e67..00000000 --- a/cli/features/crud/clients.feature +++ /dev/null @@ -1,53 +0,0 @@ -Feature: Create, Read, Update, and Delete Clients - - Background: - Given the following clients exist: - | id | name | - | 1 | One | - | 2 | Two | - | 3 | Three | - - Scenario: Index - When I enter lauth "list clients" - Then I should see - """" - 1,One - 2,Two - 3,Three - """ - - Scenario Outline: Create - When I enter lauth "create client name:" - Then I should see "" - - Examples: - | name | output | - | Four | 4,Four | - | One | 4,One | - - Scenario Outline: Read - When I enter lauth "read client " - Then I should see "" - - Examples: - | id | output | - | 4 | error: 404 "Not Found" | - | 1 | 1,One | - - Scenario Outline: Update - When I enter lauth "update client name:" - Then I should see "" - - Examples: - | id | name | output | - | 4 | Four | error: 404 "Not Found" | - | 1 | Uno | 1,Uno | - - Scenario Outline: Delete - When I enter lauth "delete client " - Then I should see "" - - Examples: - | id | output | - | 4 | error: 404 "Not Found" | - | 1 | 1,One | diff --git a/cli/features/crud/collections.feature b/cli/features/crud/collections.feature deleted file mode 100644 index abee4b37..00000000 --- a/cli/features/crud/collections.feature +++ /dev/null @@ -1,63 +0,0 @@ -Feature: Create, Read, Update, and Delete Collections - - Background: - Given the following collections exist: - | id | name | deleted | - | Identifier_1 | Collection One | f | - | Identifier_2 | Collection Two | t | - | Identifier_3 | Collection Three | f | - | Identifier_4 | Collection Four | t | - | Identifier_5 | Collection Five | f | - | Identifier_6 | Collection Six | t | - | Identifier_7 | Collection Seven | f | - | Identifier_8 | Collection Eight | t | - - Scenario: Index - When I enter lauth "list collections" - Then I should see - """" - Identifier_1,Collection One - Identifier_3,Collection Three - Identifier_5,Collection Five - Identifier_7,Collection Seven - """ - - Scenario Outline: Create - When I enter lauth "create collection name:\"\"" - Then I should see "" - - Examples: - | id | name | output | - | Identifier_4 | Four Collection | Identifier_4,Four Collection | - | Identifier_1 | One Collection | error: 403 "Forbidden" | - | Identifier_9 | Nine Collection | Identifier_9,Nine Collection | - - Scenario Outline: Read - When I enter lauth "read collection " - Then I should see "" - - Examples: - | id | output | - | Identifier_4 | error: 404 "Not Found" | - | Identifier_1 | Identifier_1,Collection One | - | Identifier_9 | error: 404 "Not Found" | - - Scenario Outline: Update - When I enter lauth "update collection name:\"\"" - Then I should see "" - - Examples: - | id | name | output | - | Identifier_4 | Four | error: 404 "Not Found" | - | Identifier_1 | One | Identifier_1,One | - | Identifier_9 | Nine | error: 404 "Not Found" | - - Scenario Outline: Delete - When I enter lauth "delete collection " - Then I should see "" - - Examples: - | id | output | - | Identifier_4 | error: 404 "Not Found" | - | Identifier_1 | Identifier_1,Collection One | - | Identifier_9 | error: 404 "Not Found" | diff --git a/cli/features/crud/groups.feature b/cli/features/crud/groups.feature deleted file mode 100644 index 09893522..00000000 --- a/cli/features/crud/groups.feature +++ /dev/null @@ -1,64 +0,0 @@ -Feature: Create, Read, Update, and Delete Groups - - Background: - Given the following groups exist: - | id | name | deleted | - | 1 | one | f | - | 2 | two | t | - | 3 | three | f | - | 4 | four | t | - | 5 | five | f | - | 6 | six | t | - | 7 | seven | f | - | 8 | eight | t | - - Scenario: Index - When I enter lauth "list groups" - Then I should see - """" - 0,root - 1,one - 3,three - 5,five - 7,seven - """ - - Scenario Outline: Create - When I enter lauth "create group name:" - Then I should see "" - - Examples: - | id | name | output | - | 4 | ruof | 4,ruof | - | 1 | eno | error: 403 "Forbidden" | - | 9 | enin | 9,enin | - - Scenario Outline: Read - When I enter lauth "read group " - Then I should see "" - - Examples: - | id | output | - | 4 | error: 404 "Not Found" | - | 1 | 1,one | - | 9 | error: 404 "Not Found" | - - Scenario Outline: Update - When I enter lauth "update group name:" - Then I should see "" - - Examples: - | id | name | output | - | 4 | ruof | error: 404 "Not Found" | - | 1 | eno | 1,eno | - | 9 | enin | error: 404 "Not Found" | - - Scenario Outline: Delete - When I enter lauth "delete group " - Then I should see "" - - Examples: - | id | output | - | 4 | error: 404 "Not Found" | - | 1 | 1,one | - | 9 | error: 404 "Not Found" | diff --git a/cli/features/crud/institutions.feature b/cli/features/crud/institutions.feature deleted file mode 100644 index 9647afe6..00000000 --- a/cli/features/crud/institutions.feature +++ /dev/null @@ -1,63 +0,0 @@ -Feature: Create, Read, Update, and Delete Institutions - - Background: - Given the following institutions exist: - | id | name | deleted | - | 1 | University of Michigan | f | - | 2 | Michigan State University | t | - | 3 | Eastern Michigan University | f | - | 4 | Western Michigan University | t | - | 5 | Wayne State University | f | - | 6 | Central Michigan University | t | - | 7 | Michigan Technology University | f | - | 8 | Oakland University | t | - - Scenario: Index - When I enter lauth "list institutions" - Then I should see - """" - 1,University of Michigan - 3,Eastern Michigan University - 5,Wayne State University - 7,Michigan Technology University - """ - - Scenario Outline: Create - When I enter lauth "create institution name:\"\"" - Then I should see "" - - Examples: - | id | name | output | - | 4 | Western Michigan | 4,Western Michigan | - | 1 | Michigan | error: 403 "Forbidden" | - | 9 | University | 9,University | - - Scenario Outline: Read - When I enter lauth "read institution " - Then I should see "" - - Examples: - | id | output | - | 4 | error: 404 "Not Found" | - | 1 | 1,University of Michigan | - | 9 | error: 404 "Not Found" | - - Scenario Outline: Update - When I enter lauth "update institution name:\"\"" - Then I should see "" - - Examples: - | id | name | output | - | 4 | Western Michigan | error: 404 "Not Found" | - | 1 | Michigan | 1,Michigan | - | 9 | University | error: 404 "Not Found" | - - Scenario Outline: Delete - When I enter lauth "delete institution " - Then I should see "" - - Examples: - | id | output | - | 4 | error: 404 "Not Found" | - | 1 | 1,University of Michigan | - | 9 | error: 404 "Not Found" | diff --git a/cli/features/crud/networks.feature b/cli/features/crud/networks.feature deleted file mode 100644 index df859517..00000000 --- a/cli/features/crud/networks.feature +++ /dev/null @@ -1,67 +0,0 @@ -Feature: Create, Read, Update, and Delete Networks - - Background: - Given the following networks exist: - | id | cidr | deleted | - | 1 | 1.2.3.3/8 | f | - | 2 | 2.2.3.3/8 | t | - | 3 | 128.0.3.3/16 | t | - | 4 | 128.1.3.3/16 | f | - | 5 | 192.0.0.3/24 | f | - | 6 | 192.0.1.3/24 | t | - - Scenario: Index - When I enter lauth "list networks" - Then I should see - """" - 1,1.0.0.0/8,allow - 4,128.1.0.0/16,allow - 5,192.0.0.0/24,allow - """ - - Scenario Outline: Create - When I enter lauth "create network cidr:\"\"" - Then I should see "" - - Examples: - | id | cidr | output | - | 4 | 128.33.1.3/16 | error: 403 "Forbidden" | - | 4 | 128.32.1.3/16 | error: 403 "Forbidden" | - | 2 | 128.33.1.3/16 | 2,128.33.0.0/16,allow | - | 2 | 128.32.1.3/16 | 2,128.32.0.0/16,allow | - | 7 | 128.33.1.3/16 | 7,128.33.0.0/16,allow | - | 7 | 128.32.1.3/16 | 7,128.32.0.0/16,allow | - - - Scenario Outline: Read - When I enter lauth "read network " - Then I should see "" - - Examples: - | id | output | - | 4 | 4,128.1.0.0/16,allow | - | 2 | error: 404 "Not Found" | - | 7 | error: 404 "Not Found" | - - Scenario Outline: Update - When I enter lauth "update network cidr:\"\"" - Then I should see "" - - Examples: - | id | cidr | output | - | 4 | 192.12.34.1/24 | 4,192.12.34.0/24,allow | - | 4 | 192.12.33.1/24 | 4,192.12.33.0/24,allow | - | 2 | 192.12.34.1/24 | error: 404 "Not Found" | - | 2 | 192.12.33.1/24 | error: 404 "Not Found" | - | 7 | 192.12.34.1/24 | error: 404 "Not Found" | - | 7 | 192.12.33.1/24 | error: 404 "Not Found" | - - Scenario Outline: Delete - When I enter lauth "delete network " - Then I should see "" - - Examples: - | id | output | - | 4 | 4,128.1.0.0/16,allow | - | 2 | error: 404 "Not Found" | - | 7 | error: 404 "Not Found" | diff --git a/cli/features/crud/users.feature b/cli/features/crud/users.feature deleted file mode 100644 index 891d5fd7..00000000 --- a/cli/features/crud/users.feature +++ /dev/null @@ -1,64 +0,0 @@ -Feature: Create, Read, Update, and Delete Users - - Background: - Given the following users exist: - | id | name | password | deleted | - | user1 | User1 | password1 | f | - | user2 | User2 | password2 | t | - | user3 | User3 | password3 | f | - | user4 | User4 | password4 | t | - | user5 | User5 | password5 | f | - | user6 | User6 | password6 | t | - | user7 | User7 | password7 | f | - | user8 | User8 | password8 | t | - - Scenario: Index - When I enter lauth "list users" - Then I should see - """" - root,User - user1,User1 - user3,User3 - user5,User5 - user7,User7 - """ - - Scenario Outline: Create - When I enter lauth "create user name:" - Then I should see "" - - Examples: - | id | name | output | - | user4 | 4resU | user4,4resU | - | user1 | 1resU | error: 403 "Forbidden" | - | user9 | 9resU | user9,9resU | - - Scenario Outline: Read - When I enter lauth "read user " - Then I should see "" - - Examples: - | id | output | - | user4 | error: 404 "Not Found" | - | user1 | user1,User1 | - | user9 | error: 404 "Not Found" | - - Scenario Outline: Update - When I enter lauth "update user name:" - Then I should see "" - - Examples: - | id | name | output | - | user4 | 4resU | error: 404 "Not Found" | - | user1 | 1resU | user1,1resU | - | user9 | 9resU | error: 404 "Not Found" | - - Scenario Outline: Delete - When I enter lauth "delete user " - Then I should see "" - - Examples: - | id | output | - | user4 | error: 404 "Not Found" | - | user1 | user1,User1 | - | user9 | error: 404 "Not Found" | diff --git a/cli/features/ipv4.feature b/cli/features/ipv4.feature deleted file mode 100644 index 55102e6b..00000000 --- a/cli/features/ipv4.feature +++ /dev/null @@ -1,145 +0,0 @@ -Feature: Internet Protocol Version 4 Utility - - Scenario: Internet Protocol (IP) Address - When I enter lauth "ipv4 128.32.0.127" - Then I should see - """ - { - 'cidr' : '128.32.0.127/32' - 'address' : '128.32.0.127' - 'prefix' : 32 - 'netmask' : '255.255.255.255' - 'network' : '128.32.0.127' - 'first_host' : '128.32.0.127' - 'last_host' : '128.32.0.127' - 'broadcast' : '128.32.0.127' - 'host_count' : 1 - } - """ - - Scenario: IP Address with Netmask - When I enter lauth "ipv4 128.32.0.127/255.255.255.0" - Then I should see - """ - { - 'cidr' : '128.32.0.127/24' - 'address' : '128.32.0.127' - 'prefix' : 24 - 'netmask' : '255.255.255.0' - 'network' : '128.32.0.0' - 'first_host' : '128.32.0.1' - 'last_host' : '128.32.0.254' - 'broadcast' : '128.32.0.255' - 'host_count' : 254 - } - """ - - Scenario: IP Address with Prefix a.k.a. Classless Inter-Domain Routing (CIDR) - When I enter lauth "ipv4 128.32.0.127/16" - Then I should see - """ - { - 'cidr' : '128.32.0.127/16' - 'address' : '128.32.0.127' - 'prefix' : 16 - 'netmask' : '255.255.0.0' - 'network' : '128.32.0.0' - 'first_host' : '128.32.0.1' - 'last_host' : '128.32.255.254' - 'broadcast' : '128.32.255.255' - 'host_count' : 65534 - } - """ - - Scenario: Prefix -1 - When I enter lauth "ipv4 128.32.0.127/-1" - Then I should see "error: Invalid netmask -1" - - Scenario: Prefix 0 - When I enter lauth "ipv4 128.32.0.127/0" - Then I should see - """ - { - 'cidr' : '128.32.0.127/0' - 'address' : '128.32.0.127' - 'prefix' : 0 - 'netmask' : '0.0.0.0' - 'network' : '0.0.0.0' - 'first_host' : '0.0.0.1' - 'last_host' : '255.255.255.254' - 'broadcast' : '255.255.255.255' - 'host_count' : 4294967294 - } - """ - - Scenario: Prefix 1 - When I enter lauth "ipv4 128.32.0.127/1" - Then I should see - """ - { - 'cidr' : '128.32.0.127/1' - 'address' : '128.32.0.127' - 'prefix' : 1 - 'netmask' : '128.0.0.0' - 'network' : '128.0.0.0' - 'first_host' : '128.0.0.1' - 'last_host' : '255.255.255.254' - 'broadcast' : '255.255.255.255' - 'host_count' : 2147483646 - } - """ - - Scenario: Prefix 30 - When I enter lauth "ipv4 128.32.0.127/30" - Then I should see - """ - { - 'cidr' : '128.32.0.127/30' - 'address' : '128.32.0.127' - 'prefix' : 30 - 'netmask' : '255.255.255.252' - 'network' : '128.32.0.124' - 'first_host' : '128.32.0.125' - 'last_host' : '128.32.0.126' - 'broadcast' : '128.32.0.127' - 'host_count' : 2 - } - """ - - Scenario: Prefix 31 - When I enter lauth "ipv4 128.32.0.127/31" - Then I should see - """ - { - 'cidr' : '128.32.0.127/31' - 'address' : '128.32.0.127' - 'prefix' : 31 - 'netmask' : '255.255.255.254' - 'network' : '128.32.0.126' - 'first_host' : '128.32.0.126' - 'last_host' : '128.32.0.127' - 'broadcast' : '128.32.0.127' - 'host_count' : 2 - } - """ - - Scenario: Prefix 32 - When I enter lauth "ipv4 128.32.0.127/32" - Then I should see - """ - { - 'cidr' : '128.32.0.127/32' - 'address' : '128.32.0.127' - 'prefix' : 32 - 'netmask' : '255.255.255.255' - 'network' : '128.32.0.127' - 'first_host' : '128.32.0.127' - 'last_host' : '128.32.0.127' - 'broadcast' : '128.32.0.127' - 'host_count' : 1 - } - """ - - Scenario: Prefix 33 - When I enter lauth "ipv4 128.32.0.127/33" - Then I should see "error: Prefix must be in range 0..32, got: 33" diff --git a/cli/features/query_networks.feature b/cli/features/query_networks.feature deleted file mode 100644 index de196583..00000000 --- a/cli/features/query_networks.feature +++ /dev/null @@ -1,24 +0,0 @@ -Feature: Query Networks - - Background: - Given the following networks exist: - | id | cidr | deleted | - | 1 | 1.2.3.3/8 | f | - | 2 | 2.2.3.3/8 | t | - | 3 | 128.0.3.3/16 | t | - | 4 | 128.1.3.3/16 | f | - | 5 | 192.0.0.3/24 | f | - | 6 | 192.0.1.3/24 | t | - - Scenario Outline: Networks include? IP Address - When I enter lauth "query networks " - Then I should see "" - - Examples: - | ip | output | - | 1.2.3.3 | 1,1.0.0.0/8 | - | 2.3.3.3 | | - | 128.0.3.3 | | - | 128.1.3.3 | 4,128.1.0.0/16 | - | 192.0.0.3 | 5,192.0.0.0/24 | - | 192.0.1.3 | | diff --git a/cli/features/step_definitions/client_steps.rb b/cli/features/step_definitions/client_steps.rb deleted file mode 100644 index b8b829ce..00000000 --- a/cli/features/step_definitions/client_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Given("the following clients exist:") do |table| - table.hashes.each do |row| - Factory[:client, id: row["id"], name: row["name"]] - end -end diff --git a/cli/features/step_definitions/colection_steps.rb b/cli/features/step_definitions/colection_steps.rb deleted file mode 100644 index adaac7d9..00000000 --- a/cli/features/step_definitions/colection_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Given("the following collections exist:") do |table| - table.hashes.each do |row| - Factory[:collection, uniqueIdentifier: row["id"], commonName: row["name"], dlpsDeleted: row["deleted"]] - end -end diff --git a/cli/features/step_definitions/group_steps.rb b/cli/features/step_definitions/group_steps.rb deleted file mode 100644 index 81a36211..00000000 --- a/cli/features/step_definitions/group_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Given("the following groups exist:") do |table| - table.hashes.each do |row| - Factory[:group, uniqueIdentifier: row["id"].to_i, commonName: row["name"], dlpsDeleted: row["deleted"]] - end -end diff --git a/cli/features/step_definitions/institution_steps.rb b/cli/features/step_definitions/institution_steps.rb deleted file mode 100644 index 382fa553..00000000 --- a/cli/features/step_definitions/institution_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Given("the following institutions exist:") do |table| - table.hashes.each do |row| - Factory[:institution, uniqueIdentifier: row["id"].to_i, organizationName: row["name"], dlpsDeleted: row["deleted"]] - end -end diff --git a/cli/features/step_definitions/lauth_steps.rb b/cli/features/step_definitions/lauth_steps.rb deleted file mode 100644 index b32f8425..00000000 --- a/cli/features/step_definitions/lauth_steps.rb +++ /dev/null @@ -1,19 +0,0 @@ -When("I enter lauth -u {string} -p {string} {string}") do |user, password, args| - @output = `bin/lauth -u #{user} -p #{password} #{args} 2>&1`.chomp -end - -When("I enter lauth {string}") do |args| - @output = `bin/lauth #{args} 2>&1`.chomp -end - -Then("I should see") do |doc_string| - expect(@output.to_s).to eq(doc_string.to_s) -end - -Then("I should see {string}") do |output| - expect(@output).to eq(output) -end - -Then('I should see "error: {int} {string}"') do |code, message| - expect(@output).to eq("error: #{code} \"#{message}\"") -end diff --git a/cli/features/step_definitions/network_steps.rb b/cli/features/step_definitions/network_steps.rb deleted file mode 100644 index 526bf9ca..00000000 --- a/cli/features/step_definitions/network_steps.rb +++ /dev/null @@ -1,22 +0,0 @@ -Given("the following networks exist:") do |table| - table.hashes.each do |row| - ip = IPAddress.parse row["cidr"] - cidr = "0.0.0.0/0" - min = 0 - max = 0xFFFFFFFF - case ip.prefix - when 32 - cidr = ip.to_string - min = max = ip.to_u32 - when 31 - cidr = ip.first.to_string - min = ip.first.to_u32 - max = ip.last.to_u32 - else - cidr = ip.network.to_string - min = ip.network.to_u32 - max = ip.broadcast.to_u32 - end - Factory[:network, uniqueIdentifier: row["id"].to_i, dlpsCIDRAddress: cidr, dlpsAddressStart: min, dlpsAddressEnd: max, dlpsDeleted: row["deleted"]] - end -end diff --git a/cli/features/step_definitions/user_steps.rb b/cli/features/step_definitions/user_steps.rb deleted file mode 100644 index 4c397458..00000000 --- a/cli/features/step_definitions/user_steps.rb +++ /dev/null @@ -1,9 +0,0 @@ -Given("user {string} with id {string} and password {string}") do |name, userid, password| - Factory[:user, userid: userid, surname: name, userPassword: password] -end - -Given("the following users exist:") do |table| - table.hashes.each do |row| - Factory[:user, userid: row["id"], surname: row["name"], userPassword: row["password"], dlpsDeleted: row["deleted"]] - end -end diff --git a/cli/features/support/env.rb b/cli/features/support/env.rb deleted file mode 100644 index de3f9771..00000000 --- a/cli/features/support/env.rb +++ /dev/null @@ -1,66 +0,0 @@ -require "./cli" -require "dotenv" -require "rom-factory" -require "database_cleaner/sequel" - -Dotenv.load - -MYSQL_DB = { - adapter: ENV["LAUTH_API_DB_ADAPTER"] || :mysql2, - host: ENV["LAUTH_API_DB_HOST"] || "localhost", - port: ENV["LAUTH_API_DB_PORT"] || 3306, - database: ENV["LAUTH_API_DB_DATABASE"] || "test", - user: ENV["LAUTH_API_DB_USER"] || "root", - password: ENV["LAUTH_API_DB_PASSWORD"] || "", - encoding: ENV["LAUTH_API_DB_ENCODING"] || "utf8mb4" -}.freeze - -MYSQL_CMD = "mysql --user=#{MYSQL_DB[:user]} --host=#{MYSQL_DB[:host]} --port=#{MYSQL_DB[:port]} --password=#{MYSQL_DB[:password]} #{MYSQL_DB[:database]}".freeze - -puts "MYSQL_DB : " + MYSQL_DB.to_s -puts "MYSQL_CMD : " + MYSQL_CMD.to_s - -LAUTH_API_ROM = ::ROM.container(:sql, MYSQL_DB) do |config| - config.auto_registration("../lib/lauth/api/rom", namespace: "Lauth::API::ROM") -end - -Factory = ROM::Factory.configure do |config| - config.rom = LAUTH_API_ROM -end - -factories_dir = File.expand_path("../../../../lib/lauth/api/factories", __FILE__) -Dir[factories_dir + "/*.rb"].sort.each { |file| require file } - -DatabaseCleaner.strategy = :truncation - -BeforeAll do - puts `./bin/lauth --user=root --password="!none" --route=http://api.lauth.local:9292 initconfig --force` - puts `cat ~/.lauth.rc` - `#{MYSQL_CMD} < ../db/drop-keys.sql 2> /dev/null` - DatabaseCleaner.clean - `#{MYSQL_CMD} < ../db/root.sql 2> /dev/null` - `#{MYSQL_CMD} < ../db/keys.sql 2> /dev/null` -end - -AfterAll do - `#{MYSQL_CMD} < ../db/drop-keys.sql 2> /dev/null` - DatabaseCleaner.clean - `#{MYSQL_CMD} < ../db/root.sql 2> /dev/null` - `#{MYSQL_CMD} < ../db/keys.sql 2> /dev/null` -end - -# NOTE: Around will mask Before and After a.k.a. XOR -# Around do |scenario, block| -# # DatabaseCleaner.cleaning(&block) -# end - -Before do - DatabaseCleaner.start -end - -After do |scenario| - `#{MYSQL_CMD} < ../db/drop-keys.sql 2> /dev/null` - DatabaseCleaner.clean - `#{MYSQL_CMD} < ../db/root.sql 2> /dev/null` - `#{MYSQL_CMD} < ../db/keys.sql 2> /dev/null` -end diff --git a/cli/lauth.rdoc b/cli/lauth.rdoc deleted file mode 100644 index 7707a3c9..00000000 --- a/cli/lauth.rdoc +++ /dev/null @@ -1,65 +0,0 @@ -== lauth - A command-line interface (CLI) for managing data in the Library Authorization system. - -v - -=== Global Options -=== -n|--username username - -Authorized user name - -[Default Value] lauth - - -=== -p|--password password - -Authorized user password - -[Default Value] ******** - - -=== -u|--url url - -Lauth API URL - -[Default Value] http://localhost:9292 - - -=== --help -Show this message - - - -=== -v|--verbose -Verbose - - - -=== Commands -==== Command: client Describe arguments to client here -Describe client here - - -==== Command: help command -Shows a list of commands or help for one command - -Gets help for the application or its commands. Can also list the commands in a way helpful to creating a bash-style completion function -===== Options -===== -c -List commands one per line, to assist with shell completion - - - -==== Command: initconfig -Initialize the config file using current global options - -Initializes a configuration file where you can set default options for command line flags, both globally and on a per-command basis. These defaults override the built-in defaults and allow you to omit commonly-used command line flags when invoking this program -===== Options -===== --[no-]force -force overwrite of existing config file - - - -==== Command: list Describe arguments to list here -Describe list here - - diff --git a/cli/spec/api_repositories/client_spec.rb b/cli/spec/api_repositories/client_spec.rb deleted file mode 100644 index 954d931c..00000000 --- a/cli/spec/api_repositories/client_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Client do - let(:repo) { described_class.new(LAUTH_API_ROM) } - let(:client) { repo.read(1) } - - it "has two clients after calling the factory twice and factory returns clients" do - client_1 = Factory[:client, id: 1] - client_2 = Factory[:client, id: 2] - expect(repo.clients.count).to eq(2) - expect(repo.clients.to_a.map(&:id)).to contain_exactly(1, 2) - expect(client_1.id).to eq(1) - expect(client_2.id).to eq(2) - expect(repo.read(1).id).to eq(1) - expect(repo.read(2).id).to eq(2) - end - - context "client" do - before { Factory[:client, id: 1, name: "Name"] } - - describe "#id" do - it "returns initialized value" do - expect(client.id).to eq(1) - end - end - - describe "#name" do - it "returns initialized value" do - expect(client.name).to eq("Name") - end - end - - describe "#resource_object" do - it "returns a valid json api resource object" do - expect(client.resource_object).to eq({type: "clients", id: client.id, attributes: {name: client.name}}) - end - end - - describe "#resource_identifier_object" do - it "returns a valid json api resource identifier object" do - expect(client.resource_identifier_object).to eq({type: "clients", id: client.id}) - end - end - end -end diff --git a/cli/spec/api_repositories/collection_spec.rb b/cli/spec/api_repositories/collection_spec.rb deleted file mode 100644 index 22b79c05..00000000 --- a/cli/spec/api_repositories/collection_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Collection do - let(:repo) { described_class.new(LAUTH_API_ROM) } - let(:collection) { repo.read("Identifier1") } - - it "has two collections after calling the factory twice" do - collection_1 = Factory[:collection, uniqueIdentifier: "Identifier1"] - collection_2 = Factory[:collection, uniqueIdentifier: "Identifier2"] - expect(repo.index.count).to eq(2) - expect(repo.index.to_a.map(&:id)).to contain_exactly("Identifier1", "Identifier2") - expect(collection_1).to eq(collection_1) - expect(collection_2).to eq(collection_2) - expect(repo.read("Identifier1").id).to eq("Identifier1") - expect(repo.read("Identifier2").id).to eq("Identifier2") - end - - context "collection" do - before { Factory[:collection, uniqueIdentifier: "Identifier1", commonName: "Collection One"] } - - describe "#id" do - it "returns initialized value" do - expect(collection.id).to eq("Identifier1") - end - end - - describe "#name" do - it "returns initialized value" do - expect(collection.name).to eq("Collection One") - end - end - - describe "#resource_object" do - it "returns a valid json api resource object" do - expect(collection.resource_object).to eq({type: "collections", id: collection.id, attributes: {name: collection.name}}) - end - end - - describe "#resource_identifier_object" do - it "returns a valid json api resource identifier object" do - expect(collection.resource_identifier_object).to eq({type: "collections", id: collection.id}) - end - end - end -end diff --git a/cli/spec/api_repositories/group_spec.rb b/cli/spec/api_repositories/group_spec.rb deleted file mode 100644 index 8d968823..00000000 --- a/cli/spec/api_repositories/group_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Group do - let(:repo) { described_class.new(LAUTH_API_ROM) } - let(:group) { repo.read(1) } - - it "has three groups after calling the factory twice but factory returns 'root' groups" do - group_1 = Factory[:group, uniqueIdentifier: 1] - group_2 = Factory[:group, uniqueIdentifier: 2] - expect(repo.index.count).to eq(3) - expect(repo.index.to_a.map(&:id)).to contain_exactly(0, 1, 2) - expect(group_1.uniqueIdentifier).to eq(0) - expect(group_2.uniqueIdentifier).to eq(0) - expect(repo.read(1).id).to eq(1) - expect(repo.read(2).id).to eq(2) - end - - context "group" do - before { Factory[:group, uniqueIdentifier: 1, commonName: "Name"] } - - describe "#id" do - it "returns initialized value" do - expect(group.id).to eq(1) - end - end - - describe "#name" do - it "returns initialized value" do - expect(group.name).to eq("Name") - end - end - - describe "#resource_object" do - it "returns a valid json api resource object" do - expect(group.resource_object).to eq({type: "groups", id: group.id, attributes: {name: group.name}}) - end - end - - describe "#resource_identifier_object" do - it "returns a valid json api resource identifier object" do - expect(group.resource_identifier_object).to eq({type: "groups", id: group.id}) - end - end - end -end diff --git a/cli/spec/api_repositories/institution_spec.rb b/cli/spec/api_repositories/institution_spec.rb deleted file mode 100644 index d1182a43..00000000 --- a/cli/spec/api_repositories/institution_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Institution do - let(:repo) { described_class.new(LAUTH_API_ROM) } - let(:institution) { repo.read(1) } - - it "has two institutions after calling the factory twice but factory returns nil institutions" do - institution_1 = Factory[:institution, uniqueIdentifier: 1] - institution_2 = Factory[:institution, uniqueIdentifier: 2] - expect(repo.index.count).to eq(2) - expect(repo.index.to_a.map(&:id)).to contain_exactly(1, 2) - expect(institution_1).to be nil - expect(institution_2).to be nil - expect(repo.read(1).id).to eq(1) - expect(repo.read(2).id).to eq(2) - end - - context "institution" do - before { Factory[:institution, uniqueIdentifier: 1, organizationName: "Name"] } - - describe "#id" do - it "returns initialized value" do - expect(institution.id).to eq(1) - end - end - - describe "#name" do - it "returns initialized value" do - expect(institution.name).to eq("Name") - end - end - - describe "#resource_object" do - it "returns a valid json api resource object" do - expect(institution.resource_object).to eq({type: "institutions", id: institution.id, attributes: {name: institution.name}}) - end - end - - describe "#resource_identifier_object" do - it "returns a valid json api resource identifier object" do - expect(institution.resource_identifier_object).to eq({type: "institutions", id: institution.id}) - end - end - end -end diff --git a/cli/spec/api_repositories/network_spec.rb b/cli/spec/api_repositories/network_spec.rb deleted file mode 100644 index e5836fc1..00000000 --- a/cli/spec/api_repositories/network_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -RSpec.describe Lauth::API::Repositories::Network do - let(:repo) { described_class.new(LAUTH_API_ROM) } - let(:network) { repo.read(1) } - - it "has two networks after calling the factory twice but factory returns nil networks" do - network_1 = Factory[:network, uniqueIdentifier: 1] - network_2 = Factory[:network, uniqueIdentifier: 2] - expect(repo.index.count).to eq(2) - expect(repo.index.to_a.map(&:id)).to contain_exactly(1, 2) - expect(network_1).to be nil - expect(network_2).to be nil - expect(repo.read(1).id).to eq(1) - expect(repo.read(2).id).to eq(2) - end - - context "network" do - before { Factory[:network, uniqueIdentifier: 1, dlpsCIDRAddress: "128.32.0.0/16"] } - - describe "#id" do - it "returns initialized value" do - expect(network.id).to eq(1) - end - end - - describe "#cidr" do - it "returns initialized value" do - expect(network.cidr).to eq("128.32.0.0/16") - end - end - - describe "#resource_object" do - it "returns a valid json api resource object" do - expect(network.resource_object).to eq({type: "networks", id: network.id, attributes: {access: network.access, cidr: network.cidr}}) - end - end - - describe "#resource_identifier_object" do - it "returns a valid json api resource identifier object" do - expect(network.resource_identifier_object).to eq({type: "networks", id: network.id}) - end - end - end -end diff --git a/cli/spec/api_repositories/user_spec.rb b/cli/spec/api_repositories/user_spec.rb deleted file mode 100644 index d4639756..00000000 --- a/cli/spec/api_repositories/user_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -RSpec.describe Lauth::API::Repositories::User do - let(:repo) { described_class.new(LAUTH_API_ROM) } - let(:user) { repo.read("user") } - - it "is initialized with a single root user" do - expect(repo.index.count).to eq(1) - expect(repo.index.one.id).to eq("root") - end - - it "has three users after calling the factory twice but factory returns the wrong users" do - a_user = Factory[:user, userid: "a_user"] - z_user = Factory[:user, userid: "z_user"] - expect(repo.index.count).to eq(3) - expect(repo.index.to_a.map(&:id)).to contain_exactly("root", "a_user", "z_user") - expect(a_user.userid).to eq("a_user") - expect(z_user.userid).not_to eq("z_user") - expect(z_user.userid).to eq("a_user") - expect(repo.read("a_user").id).to eq("a_user") - expect(repo.read("z_user").id).to eq("z_user") - end - - context "User" do - before { Factory[:user, userid: "user", surname: "Name"] } - - describe "#id" do - it "returns initialized value" do - expect(user.id).to eq("user") - end - end - - describe "#name" do - it "returns initialized value" do - expect(user.name).to eq("Name") - end - end - - describe "#resource_object" do - it "returns a valid json api resource object" do - expect(user.resource_object).to eq({type: "users", id: user.id.to_s, attributes: {name: user.name}}) - end - end - - describe "#resource_identifier_object" do - it "returns a valid json api resource identifier object" do - expect(user.resource_identifier_object).to eq({type: "users", id: user.id.to_s}) - end - end - end -end diff --git a/cli/spec/spec_helper.rb b/cli/spec/spec_helper.rb deleted file mode 100644 index 1781e158..00000000 --- a/cli/spec/spec_helper.rb +++ /dev/null @@ -1,147 +0,0 @@ -# This file was generated by the `rspec --init` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -require "./cli" -require "dotenv" -require "rom-factory" -require "database_cleaner/sequel" - -Dotenv.load - -MYSQL_DB = { - adapter: ENV["LAUTH_API_DB_ADAPTER"] || :mysql2, - host: ENV["LAUTH_API_DB_HOST"] || "localhost", - port: ENV["LAUTH_API_DB_PORT"] || 3306, - database: ENV["LAUTH_API_DB_DATABASE"] || "test", - user: ENV["LAUTH_API_DB_USER"] || "root", - password: ENV["LAUTH_API_DB_PASSWORD"] || "", - encoding: ENV["LAUTH_API_DB_ENCODING"] || "utf8mb4" -}.freeze - -MYSQL_CMD = "mysql --user=#{MYSQL_DB[:user]} --host=#{MYSQL_DB[:host]} --port=#{MYSQL_DB[:port]} --password=#{MYSQL_DB[:password]} #{MYSQL_DB[:database]}".freeze - -puts "MYSQL_DB : " + MYSQL_DB.to_s -puts "MYSQL_CMD : " + MYSQL_CMD.to_s - -LAUTH_API_ROM = ::ROM.container(:sql, MYSQL_DB) do |config| - config.auto_registration("../lib/lauth/api/rom", namespace: "Lauth::API::ROM") -end - -Factory = ROM::Factory.configure do |config| - config.rom = LAUTH_API_ROM -end - -factories_dir = File.expand_path("../../../lib/lauth/api/factories", __FILE__) -Dir[factories_dir + "/*.rb"].sort.each { |file| require file } - -DatabaseCleaner.strategy = :truncation - -RSpec.configure do |config| - config.before(:each) do - `#{MYSQL_CMD} < ../db/drop-keys.sql 2> /dev/null` - DatabaseCleaner.clean - `#{MYSQL_CMD} < ../db/root.sql 2> /dev/null` - `#{MYSQL_CMD} < ../db/keys.sql 2> /dev/null` - end - - config.after(:all) do - `#{MYSQL_CMD} < ../db/drop-keys.sql 2> /dev/null` - DatabaseCleaner.clean - `#{MYSQL_CMD} < ../db/root.sql 2> /dev/null` - `#{MYSQL_CMD} < ../db/keys.sql 2> /dev/null` - end - - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # This option will default to `:apply_to_host_groups` in RSpec 4 (and will - # have no way to turn it off -- the option exists only for backwards - # compatibility in RSpec 3). It causes shared context metadata to be - # inherited by the metadata hash of host groups and examples, rather than - # triggering implicit auto-inclusion in groups with matching metadata. - config.shared_context_metadata_behavior = :apply_to_host_groups - - # The settings below are suggested to provide a good initial experience - # with RSpec, but feel free to customize to your heart's content. - begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = ".rspec_status" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - # config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed - end -end