Skip to content

Commit 05fc317

Browse files
authored
Display aab test certificate (#189)
* Display aab test certificate * Don't make FULL call when getting aab certificate * Move attr_reader to the top
1 parent 838d0cf commit 05fc317

File tree

5 files changed

+73
-2
lines changed

5 files changed

+73
-2
lines changed

lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb

+13
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ def self.run(params)
4040
return
4141
end
4242

43+
if binary_type == :AAB && app.aab_certificate.empty?
44+
updated_app = fad_api_client.get_app(app_id)
45+
unless updated_app.aab_certificate.empty?
46+
UI.message("After you upload an AAB for the first time, App Distribution " \
47+
"generates a new test certificate. All AAB uploads are re-signed with this test " \
48+
"certificate. Use the certificate fingerprints below to register your app " \
49+
"signing key with API providers, such as Google Sign-In and Google Maps.\n" \
50+
"MD-1 certificate fingerprint: #{updated_app.aab_certificate.md5_certificate_hash}\n" \
51+
"SHA-1 certificate fingerprint: #{updated_app.aab_certificate.sha1_certificate_hash}\n" \
52+
"SHA-256 certificate fingerprint: #{updated_app.aab_certificate.sha256_certificate_hash}")
53+
end
54+
end
55+
4356
release_notes = get_value_from_value_or_file(params[:release_notes], params[:release_notes_file])
4457
fad_api_client.post_notes(app_id, release_id, release_notes)
4558

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class AabCertificate
2+
def initialize(response)
3+
@response = response || {}
4+
end
5+
6+
def md5_certificate_hash
7+
@response[:certificateHashMd5]
8+
end
9+
10+
def sha1_certificate_hash
11+
@response[:certificateHashSha1]
12+
end
13+
14+
def sha256_certificate_hash
15+
@response[:certificateHashSha256]
16+
end
17+
18+
def empty?
19+
(md5_certificate_hash.nil? || md5_certificate_hash.empty?) &&
20+
(sha1_certificate_hash.nil? || sha1_certificate_hash.empty?) &&
21+
(sha256_certificate_hash.nil? || sha256_certificate_hash.empty?)
22+
end
23+
end

lib/fastlane/plugin/firebase_app_distribution/client/app.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require_relative 'aab_certificate'
2+
13
class App
24
# AAB states
35
class AabState
@@ -10,8 +12,11 @@ class AabState
1012
UNAVAILABLE = "AAB_STATE_UNAVAILABLE"
1113
end
1214

15+
attr_reader :aab_certificate
16+
1317
def initialize(response)
1418
@response = response
19+
@aab_certificate = AabCertificate.new(response[:aabCertificate])
1520
end
1621

1722
def app_id

spec/firebase_app_distribution_action_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@
228228

229229
before { allow(File).to receive(:exist?).with('debug.aab').and_return(true) }
230230

231-
def stub_get_app(params)
231+
def stub_get_app(params, app_view = 'FULL')
232232
allow_any_instance_of(Fastlane::Client::FirebaseAppDistributionApiClient)
233233
.to receive(:get_app)
234-
.with(android_app_id, 'FULL')
234+
.with(android_app_id, app_view)
235235
.and_return(App.new({
236236
projectNumber: project_number,
237237
appId: android_app_id,

spec/firebase_app_distribution_api_client_spec.rb

+30
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,36 @@
5656
expect(app.project_number).to eq("project_number")
5757
expect(app.app_id).to eq("app_id")
5858
expect(app.contact_email).to eq("[email protected]")
59+
expect(app.aab_certificate.empty?).to eq(true)
60+
end
61+
62+
it 'returns an app with appView BASIC and aab certificate' do
63+
response = {
64+
projectNumber: "project_number",
65+
appId: "app_id",
66+
contactEmail: "[email protected]",
67+
aabCertificate: {
68+
certificateHashMd5: "md5-cert-hash",
69+
certificateHashSha1: "sha1-cert-hash",
70+
certificateHashSha256: "sha256-cert-hash"
71+
}
72+
}
73+
stubs.get("/v1alpha/apps/app_id?appView=BASIC", headers) do |env|
74+
[
75+
200,
76+
{},
77+
response
78+
]
79+
end
80+
app = api_client.get_app("app_id")
81+
binary_hash = Digest::SHA256.hexdigest(fake_binary_contents)
82+
expect(app.project_number).to eq("project_number")
83+
expect(app.app_id).to eq("app_id")
84+
expect(app.contact_email).to eq("[email protected]")
85+
expect(app.aab_certificate.empty?).to eq(false)
86+
expect(app.aab_certificate.md5_certificate_hash).to eq("md5-cert-hash")
87+
expect(app.aab_certificate.sha1_certificate_hash).to eq("sha1-cert-hash")
88+
expect(app.aab_certificate.sha256_certificate_hash).to eq("sha256-cert-hash")
5989
end
6090

6191
it 'returns an app with appView FULL' do

0 commit comments

Comments
 (0)