Skip to content

Commit

Permalink
Merge pull request #132 from DeployGate/work/2step_login
Browse files Browse the repository at this point in the history
Fixed 2 step auth login
  • Loading branch information
henteko authored Sep 20, 2016
2 parents f6deaa2 + cd6873a commit 60fa77a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 46 deletions.
6 changes: 3 additions & 3 deletions deploygate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ POST_INSTALL_MESSAGE
spec.add_dependency 'workers'

# ios build
spec.add_dependency 'gym', '~> 1.8.0'
spec.add_dependency 'spaceship', '~> 0.32.0'
spec.add_dependency 'sigh', '~> 1.10.0'
spec.add_dependency 'gym', '~> 1.9.0'
spec.add_dependency 'spaceship', '~> 0.32.4'
spec.add_dependency 'sigh', '~> 1.10.4'

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
Expand Down
8 changes: 4 additions & 4 deletions lib/deploygate/xcode/member_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ module DeployGate
module Xcode
class MemberCenter
include Singleton
attr_reader :email, :method, :team
attr_reader :email, :method, :team, :launcher

def initialize
@email = input_email
Spaceship.login @email
@team = Spaceship.select_team
@launcher = Spaceship::Launcher.new @email
@team = @launcher.select_team

if Spaceship.client.in_house?
if @launcher.client.in_house?
@method = Export::ENTERPRISE
else
@method = Export::AD_HOC
Expand Down
4 changes: 2 additions & 2 deletions lib/deploygate/xcode/member_centers/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(uuid)

# @return [Boolean]
def created?
Spaceship.app.all.collect do |app|
@member_center.launcher.app.all.collect do |app|
return true if app.bundle_id == @uuid
end

Expand All @@ -22,7 +22,7 @@ def created?

# @return [void]
def create!
Spaceship.app.create!(bundle_id: @uuid, name: name())
@member_center.launcher.app.create!(bundle_id: @uuid, name: name())
end

# @return [String]
Expand Down
8 changes: 4 additions & 4 deletions lib/deploygate/xcode/member_centers/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ def initialize(udid, user_name, device_name)
end

def registered?
DeployGate::Xcode::MemberCenter.instance
!Spaceship::Device.find_by_udid(@udid).nil?
instance = DeployGate::Xcode::MemberCenter.instance
!instance.launcher.device.find_by_udid(@udid).nil?
end

# @return [void]
def register!
DeployGate::Xcode::MemberCenter.instance
instance = DeployGate::Xcode::MemberCenter.instance
return if registered?

Spaceship::Device.create!(name: @register_name, udid: @udid)
instance.launcher.device.create!(name: @register_name, udid: @udid)
end

# @return [String]
Expand Down
8 changes: 4 additions & 4 deletions lib/deploygate/xcode/member_centers/provisioning_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def create!(uuid = nil)
# @return [Array]
def all_create
if @member_center.adhoc?
prod_certs = Spaceship.certificate.production.all
prod_certs = @member_center.launcher.certificate.production.all
else
prod_certs = Spaceship.certificate.all.reject{|cert| cert.class != Spaceship::Portal::Certificate::InHouse}
prod_certs = @member_center.launcher.certificate.all.reject{|cert| cert.class != Spaceship::Portal::Certificate::InHouse}
end

# check local install certificate
Expand All @@ -65,7 +65,7 @@ def all_create
# @param [String] uuid
# @return [String]
def download(uuid)
profiles = Spaceship.provisioning_profile.all.reject!{|p| p.uuid != uuid}
profiles = @member_center.launcher.provisioning_profile.all.reject!{|p| p.uuid != uuid}

raise NotExistUUIDProvisioningProfileError, I18n.t('xcode.member_center.provisioning_profile.not_exist_uuid_provisioning_profile_error', uuid: uuid) if profiles.empty?
select_profile = profiles.first
Expand All @@ -91,7 +91,7 @@ def sigh_config_values(adhoc: @member_center.adhoc?, provisioning_name: nil, cer
app_identifier: @app_identifier,
username: @member_center.email,
output_path: OUTPUT_PATH,
team_id: Spaceship.client.team_id,
team_id: @member_center.launcher.client.team_id,
force: true
}
values.merge!({provisioning_name: provisioning_name}) unless provisioning_name.nil?
Expand Down
6 changes: 3 additions & 3 deletions spec/deploygate/xcode/member_center_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ def in_house?
let(:email) { '[email protected]' }
let(:center) { DeployGate::Xcode::MemberCenter.instance }
before do
allow(Spaceship).to receive(:login) {}
allow(Spaceship).to receive(:select_team) {}
allow(Spaceship).to receive(:client).and_return(SpaceshipClient.new)
allow_any_instance_of(Spaceship::PortalClient).to receive(:login) {}
allow_any_instance_of(Spaceship::PortalClient).to receive(:teams) {['team_name', 'team_id']}
allow_any_instance_of(Spaceship::Launcher).to receive(:select_team) {}
allow_any_instance_of(DeployGate::Xcode::MemberCenter).to receive(:input_email).and_return(email)
end

Expand Down
40 changes: 14 additions & 26 deletions spec/deploygate/xcode/member_centers/app_spec.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
describe DeployGate::Xcode::MemberCenters::App do
before do
allow_any_instance_of(DeployGate::Xcode::MemberCenter).to receive(:instance) {}
allow(Spaceship).to receive(:app).and_return(SpaceshipApp.new(uuid))
end

class SpaceshipApp
attr_reader :bundle_id
def initialize(bundle_id)
@bundle_id = bundle_id
end
def create!(options)
end
let(:email) { '[email protected]' }
let(:registered_uuid) { 'com.example.test.registered' }
let(:non_registered_uuid) { 'com.example.test.non.registered' }
let(:app) { DeployGate::Xcode::MemberCenters::App.new('com.example.test.new.app') }

def all
end
before do
allow_any_instance_of(Spaceship::PortalClient).to receive(:login) {}
allow_any_instance_of(Spaceship::PortalClient).to receive(:teams) {['team_name', 'team_id']}
allow_any_instance_of(Spaceship::Launcher).to receive(:select_team) {}
allow_any_instance_of(Spaceship::PortalClient).to receive(:apps) {[
{"identifier" => registered_uuid}
]}
allow_any_instance_of(DeployGate::Xcode::MemberCenter).to receive(:input_email).and_return(email)
end

let(:uuid) { 'com.example.test' }
let(:app) { DeployGate::Xcode::MemberCenters::App.new(uuid) }

context "#created?" do
let(:registered_uuid) { 'com.example.test.registered' }
let(:non_registered_uuid) { 'com.example.test.non.registered' }

before do
allow_any_instance_of(SpaceshipApp).to receive(:all) do
[SpaceshipApp.new(registered_uuid)]
end
end

it "app created" do
app = DeployGate::Xcode::MemberCenters::App.new(registered_uuid)
Expand All @@ -45,7 +33,7 @@ def all
context "#create!" do
it "must call Spaceshio.app.create!" do
call_create = false
allow_any_instance_of(SpaceshipApp).to receive(:create!) { call_create = true }
allow(Spaceship::Portal::App).to receive(:create!) { call_create = true }

app.create!
expect(call_create).to be_truthy
Expand All @@ -54,7 +42,7 @@ def all

context "#name" do
it "get name" do
expect(app.name).to eq 'com example test'
expect(app.name).to eq 'com example test new app'
end
end
end

0 comments on commit 60fa77a

Please sign in to comment.