|
17 | 17 |
|
18 | 18 | module Google |
19 | 19 | module Apis |
20 | | - module CloudkmsV1 |
21 | | - class DecryptResponse |
| 20 | + module SecretmanagerV1 |
| 21 | + class AccessSecretVersionResponse |
| 22 | + end |
| 23 | + class SecretPayload |
22 | 24 | end |
23 | 25 | end |
24 | 26 | end |
@@ -526,23 +528,75 @@ class DecryptResponse |
526 | 528 | command.execute(client) |
527 | 529 | end |
528 | 530 |
|
529 | | - describe "#safe_object_representation" do |
| 531 | + describe "#safe_pretty_representation" do |
| 532 | + let(:command) do |
| 533 | + Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals') |
| 534 | + end |
| 535 | + |
| 536 | + it "should show fields in a normal object" do |
| 537 | + obj = Google::Apis::SecretmanagerV1::AccessSecretVersionResponse.new |
| 538 | + obj.instance_variable_set(:@payload, "hello") |
| 539 | + str = command.send(:safe_pretty_representation, obj) |
| 540 | + expect(str).to include("@payload") |
| 541 | + expect(str).not_to include("(fields redacted)") |
| 542 | + expect(str).to include("\n") |
| 543 | + end |
| 544 | + |
| 545 | + it "should not show fields in a restricted object" do |
| 546 | + obj = Google::Apis::SecretmanagerV1::SecretPayload.new |
| 547 | + obj.instance_variable_set(:@payload, "hello") |
| 548 | + str = command.send(:safe_pretty_representation, obj) |
| 549 | + expect(str).not_to include("@payload") |
| 550 | + expect(str).to include("(fields redacted)") |
| 551 | + expect(str).to include("\n") |
| 552 | + end |
| 553 | + |
| 554 | + it "should not show fields in a nested restricted object" do |
| 555 | + obj = Google::Apis::SecretmanagerV1::AccessSecretVersionResponse.new |
| 556 | + payload = Google::Apis::SecretmanagerV1::SecretPayload.new |
| 557 | + payload.instance_variable_set(:@data, "whoops") |
| 558 | + obj.instance_variable_set(:@payload, payload) |
| 559 | + str = command.send(:safe_pretty_representation, obj) |
| 560 | + expect(str).to include("@payload") |
| 561 | + expect(str).not_to include("@data") |
| 562 | + expect(str).to include("(fields redacted)") |
| 563 | + expect(str).to include("\n") |
| 564 | + end |
| 565 | + end |
| 566 | + |
| 567 | + describe "#safe_single_line_representation" do |
530 | 568 | let(:command) do |
531 | 569 | Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals') |
532 | 570 | end |
533 | 571 |
|
534 | 572 | it "should show fields in a normal object" do |
535 | | - obj = Object.new |
536 | | - obj.instance_variable_set(:@foobar, "hi") |
537 | | - str = command.send(:safe_object_representation, obj) |
538 | | - expect(str).to match /@foobar/ |
| 573 | + obj = Google::Apis::SecretmanagerV1::AccessSecretVersionResponse.new |
| 574 | + obj.instance_variable_set(:@payload, "hello") |
| 575 | + str = command.send(:safe_single_line_representation, obj) |
| 576 | + expect(str).to include("@payload") |
| 577 | + expect(str).not_to include("(fields redacted)") |
| 578 | + expect(str).not_to include("\n") |
539 | 579 | end |
540 | 580 |
|
541 | 581 | it "should not show fields in a restricted object" do |
542 | | - obj = Google::Apis::CloudkmsV1::DecryptResponse.new |
543 | | - obj.instance_variable_set(:@foobar, "hi") |
544 | | - str = command.send(:safe_object_representation, obj) |
545 | | - expect(str).not_to match /@foobar/ |
| 582 | + obj = Google::Apis::SecretmanagerV1::SecretPayload.new |
| 583 | + obj.instance_variable_set(:@payload, "hello") |
| 584 | + str = command.send(:safe_single_line_representation, obj) |
| 585 | + expect(str).not_to include("@payload") |
| 586 | + expect(str).to include("(fields redacted)") |
| 587 | + expect(str).not_to include("\n") |
| 588 | + end |
| 589 | + |
| 590 | + it "should not show fields in a nested restricted object" do |
| 591 | + obj = Google::Apis::SecretmanagerV1::AccessSecretVersionResponse.new |
| 592 | + payload = Google::Apis::SecretmanagerV1::SecretPayload.new |
| 593 | + payload.instance_variable_set(:@data, "whoops") |
| 594 | + obj.instance_variable_set(:@payload, payload) |
| 595 | + str = command.send(:safe_single_line_representation, obj) |
| 596 | + expect(str).to include("@payload") |
| 597 | + expect(str).not_to include("@data") |
| 598 | + expect(str).to include("(fields redacted)") |
| 599 | + expect(str).not_to include("\n") |
546 | 600 | end |
547 | 601 | end |
548 | 602 | end |
0 commit comments