As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects

Passing pushauth flag as bool in json body to internal api doesn't become a...

Open Manoj Memana Jayakumar requested to merge mmj/gitlab-shell:506-jsandlin into main
2 files
+ 74
27
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -3,7 +3,7 @@ require_relative 'spec_helper'
require 'open3'
require 'json'
describe 'bin/gitlab-shell 2fa_verify' do
describe 'bin/gitlab-shell 2fa_verify manual' do
include_context 'gitlab shell'
let(:env) do
@@ -16,7 +16,7 @@ describe 'bin/gitlab-shell 2fa_verify' do
end
def mock_server(server)
server.mount_proc('/api/v4/internal/two_factor_otp_check') do |req, res|
server.mount_proc('/api/v4/internal/two_factor_manual_otp_check') do |req, res|
res.content_type = 'application/json'
res.status = 200
@@ -24,15 +24,7 @@ describe 'bin/gitlab-shell 2fa_verify' do
key_id = params['key_id'] || params['user_id'].to_s
if key_id == '100'
if params['push_auth'] == "true"
res.body = { success: false }.to_json
else
res.body = { success: true }.to_json
end
elsif key_id == '102'
if params['push_auth'] == "true"
res.body = { success: true }.to_json
end
res.body = { success: true }.to_json
else
res.body = { success: false, message: 'boom!' }.to_json
end
@@ -46,14 +38,6 @@ describe 'bin/gitlab-shell 2fa_verify' do
end
describe 'command' do
context 'when push is provided' do
let(:cmd) { "#{gitlab_shell_path} key-102" }
it 'prints a successful push verification message' do
verify_successful_verification_push!(cmd)
end
end
context 'when key is provided' do
let(:cmd) { "#{gitlab_shell_path} key-100" }
@@ -94,12 +78,4 @@ describe 'bin/gitlab-shell 2fa_verify' do
expect(stdout.flush.read).to eq("\nOTP validation successful. Git operations are now allowed.\n")
end
end
def verify_successful_verification_push!(cmd)
Open3.popen2(env, cmd) do |stdin, stdout|
expect(stdout.gets(5)).to eq('OTP: ')
expect(stdout.flush.read).to eq("\nPush OTP validation successful. Git operations are now allowed.\n")
end
end
end
Loading